diff --git a/project/jni/application/gemrb/AndroidAppSettings.cfg b/project/jni/application/gemrb/AndroidAppSettings.cfg index f65c94933..efda239cb 100644 --- a/project/jni/application/gemrb/AndroidAppSettings.cfg +++ b/project/jni/application/gemrb/AndroidAppSettings.cfg @@ -1,11 +1,11 @@ # The application settings for Android libSDL port -AppSettingVersion=15 +AppSettingVersion=16 LibSdlVersion=1.2 AppName="GemRB" AppFullName=net.sourceforge.gemrb ScreenOrientation=h InhibitSuspend=n -AppDataDownloadUrl="GemRB data(local)|data.zip" +AppDataDownloadUrl="GemRB data(local)|data1.zip" SdlVideoResize=y SdlVideoResizeKeepAspect=y NeedDepthBuffer=n @@ -20,12 +20,13 @@ NonBlockingSwapBuffers=n RedefinedKeys="LCTRL c p o e" AppTouchscreenKeyboardKeysAmount=0 AppTouchscreenKeyboardKeysAmountAutoFire=0 +RedefinedKeysScreenKb="LCTRL c p o e" MultiABI=y -AppVersionCode=063 -AppVersionName="0.6.3" +AppVersionCode=0631 +AppVersionName="0.6.3.1" CompiledLibraries="sdl_mixer ogg vorbis openal png python" CustomBuildScript=n -AppCflags='-fexceptions -finline-functions -O2 -DSTATIC_LINK=Yes' +AppCflags='-fexceptions -finline-functions -O3 -DSTATIC_LINK=Yes -DHAVE_SNPRINTF -DTOUCHSCREEN' AppLdflags='' AppSubdirsBuild='' AppUseCrystaXToolchain=y diff --git a/project/jni/application/gemrb/AndroidData/data.zip b/project/jni/application/gemrb/AndroidData/data1.zip similarity index 66% rename from project/jni/application/gemrb/AndroidData/data.zip rename to project/jni/application/gemrb/AndroidData/data1.zip index 8b60a6777..cb1398243 100644 Binary files a/project/jni/application/gemrb/AndroidData/data.zip and b/project/jni/application/gemrb/AndroidData/data1.zip differ diff --git a/project/jni/application/gemrb/gemrb/CMakeLists.txt b/project/jni/application/gemrb/gemrb/CMakeLists.txt new file mode 100644 index 000000000..199dd2108 --- /dev/null +++ b/project/jni/application/gemrb/gemrb/CMakeLists.txt @@ -0,0 +1,35 @@ +ADD_SUBDIRECTORY( core ) +ADD_SUBDIRECTORY( plugins ) +ADD_SUBDIRECTORY( override ) +ADD_SUBDIRECTORY( GUIScripts ) +ADD_SUBDIRECTORY( docs ) +ADD_SUBDIRECTORY( tests ) + +ADD_EXECUTABLE(gemrb GemRB.cpp ) +SET_TARGET_PROPERTIES(gemrb PROPERTIES INSTALL_RPATH ${LIB_DIR}) +INCLUDE_DIRECTORIES( ${SDL_INCLUDE_DIR} ) +IF(WIN32) + TARGET_LINK_LIBRARIES(gemrb gemrb_core) +ELSE(WIN32) + IF(APPLE) + TARGET_LINK_LIBRARIES(gemrb gemrb_core ${SDL_LIBRARY} + ${SDL_MAIN_LIBRARY_PATH} ${COCOA_LIBRARY_PATH} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + ELSE(APPLE) + if (STATIC_LINK) + TARGET_LINK_LIBRARIES(gemrb ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} + -Wl,--whole-archive gemrb_core ${plugins} -Wl,--no-whole-archive) + else (STATIC_LINK) + TARGET_LINK_LIBRARIES(gemrb gemrb_core ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + endif (STATIC_LINK) + ENDIF(APPLE) +ENDIF(WIN32) + +# preconfigure the sample config with the selected paths +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/GemRB.cfg.sample.in" + "${CMAKE_CURRENT_BINARY_DIR}/GemRB.cfg.sample" + IMMEDIATE @ONLY +) + +INSTALL( TARGETS gemrb DESTINATION ${BIN_DIR} ) +INSTALL( FILES "${CMAKE_CURRENT_BINARY_DIR}/GemRB.cfg.sample" GemRB.cfg.noinstall.sample DESTINATION ${SYSCONF_DIR} ) diff --git a/project/jni/application/gemrb/gemrb/GemRB.cfg.noinstall.sample b/project/jni/application/gemrb/gemrb/GemRB.cfg.noinstall.sample new file mode 100644 index 000000000..1f2261507 --- /dev/null +++ b/project/jni/application/gemrb/gemrb/GemRB.cfg.noinstall.sample @@ -0,0 +1,254 @@ +##################################################### +# # +# This is the GemRB Configuration file. # +# Here are defined some default parameters for # +# basic configuration and paths definition. # +# # +# Parameters are defined as a Name=Value pair # +# The Value can be of three types: # +# - String # +# - Integer # +# - Boolean # +# # +# The String value is represented as follows # +# i.e. H:\GemRB\plugins # +# Integers are defined as follows # +# i.e. 12723 # +# Booleans are represented as 1 or 0 in this file # +# # +# Lines starting with # are ignored # +# # +##################################################### + +##################################################### +# # +# Game Type [String] Use one of the following # +# values: # +# # +# bg1 Baldur's Gate # +# bg2 Baldur's Gate 2 : SoA or ToB # +# tob Baldur's Gate 2 : ToB (obsolete) # +# iwd IceWind Dale # +# how IceWind Dale : HoW or ToTL # +# iwd2 IceWind Dale 2 # +# pst Planescape Torment # +# (More will come) # +# # +##################################################### + +GameType=test + +##################################################### +# Game Name [String] Title for GemRB window, use # +# anything you wish, e.g. Baldur's Gate 3: RotFL # +##################################################### + +GameName=Baldur's Gate 2 + +##################################################### +# Video Parameters # +##################################################### + +#Screen width +Width=640 + +#Screen height +Height=480 + +#Bits per pixel [Integer:16,32] +Bpp=32 + +#Fullscreen [Boolean] +Fullscreen=0 + +# Delay before tooltips appear [milliseconds] +TooltipDelay=500 + +##################################################### +# Audio Parameters # +##################################################### +# # +# All volume options are in percents, with 100 # +# being the normal and default volume # +# # +##################################################### + +# Choices: openal (default), sdlaudio (faster, but limited featureset), none +#AudioDriver = openal + +# Volume of ambient sounds +#VolumeAmbients = 100 + +# Volume during movie playback +#VolumeMovie = 100 + +# Volume of background music +#VolumeMusic = 100 + +# Volume of sound effects +#VolumeSFX = 100 + +# Volume of PC or NPC voices +#VolumeVoices = 100 + +##################################################### +# Case Sensitive Filesystem [Boolean] # +# # +# If your installed game files are residing on a # +# case sensitive filesystem (ext2 on Linux) then # +# you need to set this value to 1, it has no # +# effect on Windows # +##################################################### + +#CaseSensitive=1 + +#GameOnCD=0 + +##################################################### +# GUI Parameters # +##################################################### +# # +# GemRB may enhance the GUI of the Infinity Engine # +# games (so far only in bg2) creating functionally # +# new buttons or scrollbars where they weren't # +# present in original games. It may improve its # +# usability, but is not quite compatible with # +# mods changing graphics and alignment in the *.chu # +# files (e.g. the buttons will appear in old # +# coordinates and may stop being clickable). # +##################################################### + +# Enable all gui enhancements ? [Boolean] +GUIEnhancements = 1 + + +##################################################### +# Debug # +##################################################### + +# Do not play intro videos [Boolean], useful for development +#SkipIntroVideos=1 + +# Draw Frames per Second info [Boolean] +#DrawFPS=1 + +# Hide unexplored parts of a map +#FogOfWar=1 + +# Enable debug and cheat keystrokes, see docs/en/CheatKeys.txt +# full listing +#EnableCheatKeys=1 + +##################################################### +# Paths # +##################################################### + +##################################################### +# Game Paths [String] # +# # +# These are the paths where the Game you want to # +# play is installed. # +# Enter the full path to the directory. # +##################################################### + +GamePath=../gemrb/tests/minimal +CD1=/mnt/windows/Programmi/Black Isle/BGII - SoA/ +CD2=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD2/ +CD3=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD3/ +CD4=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD4/ +CD5=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD5/ + +##################################################### +# GemRB Cache Path [String] # +# # +# This is the path where GemRB will store the # +# cached files, enter the full path to the GemRB # +# Cache directory. # +##################################################### + +CachePath=./gemrb/Cache/ + +##################################################### +# GemRB Save Path [String] # +# # +# This is the path where GemRB looks for saved # +# games. # +# Enter the full path to the directory containing # +# e.g. the 'save' subdirectory. # +# # +# You do not have to specify this if you use save # +# subdir in the GamePath directory. # +##################################################### + +#SavePath=/mnt/windows/Programmi/Black Isle/BGII - SoA/ + +##################################################### +# GemRB Path [String] # +# # +# This is the path where GemRB is stored, just # +# enter the full path to the GemRB executable # +##################################################### + +GemRBPath=../gemrb + +##################################################### +# GemRB GUI Scripts Path [String] # +# # +# This is the path where GemRB GUI scripts are # +# stored, usually these are in the GemRB directory # +# Enter the full path to the directory containing # +# the 'GUIScript' subdirectory. # +##################################################### + +#GUIScriptsPath=./ + +##################################################### +# GemRB Plugins Path [String] # +# # +# This is the path containing GemRB plugins # +# - shared libraries (.so) on Unixes, or # +# DLLs (.dll) on windows. # +# Enter the full path to the directory. # +# # +# You may need to specify this path if running # +# GemRB from source directory on Linux. # +##################################################### + +PluginsPath=./gemrb/plugins/ + +##################################################### +# Game Data Path [String] # +# # +# This is the subdirectory under GamePath where # +# game data files are stored. # +# # +# You probably do NOT want to specify this! # +##################################################### + +#GameDataPath=data + +##################################################### +# Game Data Override Path [String] # +# # +# This is the subdirectory under GamePath where # +# game data override files are stored. # +# # +# You probably do NOT want to specify this! # +##################################################### + +#GameOverridePath=override + +##################################################### +# GemRB Data Override Path [String] # +# # +# This is the path where GemRB looks for the GemRB # +# data override directory. # +# # +# You probably do NOT want to specify this! # +##################################################### + +#GemRBOverridePath=/usr/share/games/gemrb + +##################################################### +# END # +##################################################### diff --git a/project/jni/application/gemrb/gemrb/GemRB.cfg.sample.in b/project/jni/application/gemrb/gemrb/GemRB.cfg.sample.in new file mode 100644 index 000000000..4b4dfbdac --- /dev/null +++ b/project/jni/application/gemrb/gemrb/GemRB.cfg.sample.in @@ -0,0 +1,259 @@ +##################################################### +# # +# This is the GemRB Configuration file. # +# Here are defined some default parameters for # +# basic configuration and paths definition. # +# # +# Parameters are defined as a Name=Value pair # +# The Value can be of three types: # +# - String # +# - Integer # +# - Boolean # +# # +# The String value is represented as follows # +# i.e. H:\GemRB\plugins # +# Integers are defined as follows # +# i.e. 12723 # +# Booleans are represented as 1 or 0 in this file # +# # +# Lines starting with # are ignored # +# # +##################################################### + +##################################################### +# # +# Game Type [String] Use one of the following # +# values: # +# # +# bg1 Baldur's Gate # +# bg2 Baldur's Gate 2 : SoA or ToB # +# tob Baldur's Gate 2 : ToB (obsolete) # +# iwd IceWind Dale # +# how IceWind Dale : HoW or ToTL # +# iwd2 IceWind Dale 2 # +# pst Planescape Torment # +# (More will come) # +# # +##################################################### + +GameType=bg2 + +##################################################### +# Game Name [String] Title for GemRB window, use # +# anything you wish, e.g. Baldur's Gate 3: RotFL # +##################################################### + +GameName=Baldur's Gate 2 + +##################################################### +# Video Parameters # +##################################################### + +#Screen width +Width=640 + +#Screen height +Height=480 + +#Bits per pixel [Integer:16,32] +Bpp=32 + +#Fullscreen [Boolean] +Fullscreen=0 + +# Delay before tooltips appear [milliseconds] +TooltipDelay=500 + +##################################################### +# Audio Parameters # +##################################################### +# # +# All volume options are in percents, with 100 # +# being the normal and default volume # +# # +##################################################### + +# Choices: openal (default), sdlaudio (faster, but limited featureset), none +#AudioDriver = openal + +# Volume of ambient sounds +#VolumeAmbients = 100 + +# Volume during movie playback +#VolumeMovie = 100 + +# Volume of background music +#VolumeMusic = 100 + +# Volume of sound effects +#VolumeSFX = 100 + +# Volume of PC or NPC voices +#VolumeVoices = 100 + +##################################################### +# Case Sensitive Filesystem [Boolean] # +# # +# If your installed game files are residing on a # +# case sensitive filesystem (ext2 on Linux) then # +# you need to set this value to 1, it has no # +# effect on Windows # +##################################################### + +#CaseSensitive=1 + +#GameOnCD=0 + +##################################################### +# GUI Parameters # +##################################################### +# # +# GemRB may enhance the GUI of the Infinity Engine # +# games (so far only in bg2) creating functionally # +# new buttons or scrollbars where they weren't # +# present in original games. It may improve its # +# usability, but is not quite compatible with # +# mods changing graphics and alignment in the *.chu # +# files (e.g. the buttons will appear in old # +# coordinates and may stop being clickable). # +##################################################### + +# Enable all gui enhancements ? [Boolean] +GUIEnhancements = 1 + + +##################################################### +# Debug # +##################################################### + +# Do not play intro videos [Boolean], useful for development +#SkipIntroVideos=1 + +# Draw Frames per Second info [Boolean] +#DrawFPS=1 + +# Hide unexplored parts of a map +#FogOfWar=1 + +# Enable debug and cheat keystrokes, see docs/en/CheatKeys.txt +# full listing +#EnableCheatKeys=1 + +##################################################### +# Paths # +##################################################### + +##################################################### +# Game Paths [String] # +# # +# These are the paths where the Game you want to # +# play is installed. # +# Enter the full path to the directory. # +##################################################### + +GamePath=/mnt/windows/Programmi/Black Isle/BGII - SoA/ +CD1=/mnt/windows/Programmi/Black Isle/BGII - SoA/ +CD2=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD2/ +CD3=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD3/ +CD4=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD4/ +CD5=/mnt/windows/Programmi/Black Isle/BGII - SoA/CD5/ + +##################################################### +# GemRB Cache Path [String] # +# # +# This is the path where GemRB will store the # +# cached files, enter the full path to the GemRB # +# Cache directory. # +##################################################### + +CachePath=./Cache/ + +##################################################### +# GemRB Save Path [String] # +# # +# This is the path where GemRB looks for saved # +# games. # +# Enter the full path to the directory containing # +# e.g. the 'save' subdirectory. # +# # +# You do not have to specify this if you use save # +# subdir in the GamePath directory. # +##################################################### + +#SavePath=/mnt/windows/Programmi/Black Isle/BGII - SoA/ + +###### HERE BE DRAGONS ############################# +###### HERE BE DRAGONS ############################# +###### HERE BE DRAGONS ############################# +# You shouldn't need to change anything below this point. + +##################################################### +# GemRB Path [String] # +# # +# This is the path where GemRB is stored, just # +# enter the full path to the GemRB executable # +##################################################### + +#GemRBPath=@DATA_DIR@ + +##################################################### +# GemRB GUI Scripts Path [String] # +# # +# This is the path where GemRB GUI scripts are # +# stored, usually these are in the GemRB directory # +# Enter the full path to the directory containing # +# the 'GUIScript' subdirectory. # +##################################################### + +#GUIScriptsPath=@DATA_DIR@ + +##################################################### +# GemRB Plugins Path [String] # +# # +# This is the path containing GemRB plugins # +# - shared libraries (.so) on Unixes, or # +# DLLs (.dll) on windows. # +# Enter the full path to the directory. # +# # +# You may need to specify this path if running # +# GemRB from source directory on Linux. # +##################################################### + +#PluginsPath=@PLUGIN_DIR@ + +##################################################### +# Game Data Path [String] # +# # +# This is the subdirectory under GamePath where # +# game data files are stored. # +# # +# You probably do NOT want to specify this! # +##################################################### + +#GameDataPath=data + +##################################################### +# Game Data Override Path [String] # +# # +# This is the subdirectory under GamePath where # +# game data override files are stored. # +# # +# You probably do NOT want to specify this! # +##################################################### + +#GameOverridePath=override + +##################################################### +# GemRB Data Override Path [String] # +# # +# This is the path where GemRB looks for the GemRB # +# data override directory. # +# # +# You probably do NOT want to specify this! # +##################################################### + +#GemRBOverridePath=@DATA_DIR@ + +##################################################### +# END # +##################################################### diff --git a/project/jni/application/gemrb/src/GemRB.cpp b/project/jni/application/gemrb/gemrb/GemRB.cpp similarity index 93% rename from project/jni/application/gemrb/src/GemRB.cpp rename to project/jni/application/gemrb/gemrb/GemRB.cpp index fecabd6e2..9f8b08b75 100644 --- a/project/jni/application/gemrb/src/GemRB.cpp +++ b/project/jni/application/gemrb/gemrb/GemRB.cpp @@ -34,7 +34,7 @@ #endif #ifdef ANDROID -#include +#include #include "audio.h" // pause audio playing if app goes in background @@ -52,9 +52,6 @@ static void appPutToForeground() int main(int argc, char* argv[]) { -#ifdef ANDROID - SDL_ANDROID_SetApplicationPutToBackgroundCallback(&appPutToBackground, &appPutToForeground); -#endif Interface::SanityCheck(VERSION_GEMRB); core = new Interface( argc, argv ); if (core->Init() == GEM_ERROR) { @@ -64,6 +61,9 @@ int main(int argc, char* argv[]) getc(stdin); return -1; } +#ifdef ANDROID + SDL_ANDROID_SetApplicationPutToBackgroundCallback(&appPutToBackground, &appPutToForeground); +#endif core->Main(); delete( core ); textcolor(DEFAULT); diff --git a/project/jni/application/gemrb/gemrb/Makefile.am b/project/jni/application/gemrb/gemrb/Makefile.am new file mode 100644 index 000000000..4feac3dab --- /dev/null +++ b/project/jni/application/gemrb/gemrb/Makefile.am @@ -0,0 +1,13 @@ +bin_PROGRAMS = gemrb +sysconf_DATA = GemRB.cfg.sample.in +gemrb_SOURCES = GemRB.cpp + +gemrb_LDADD = ./core/libgemrb_core.la + +SUBDIRS = core plugins includes GUIScripts override docs +EXTRA_DIST = GemRB.cfg* plugins-prepare.sh CMakeLists.txt + +gemrb_LDFLAGS = $(all_libraries) @LIBPTHREAD@ + +#install-data-local: +# $(INSTALL_DATA) GemRB.cfg* $(sysconfdir) diff --git a/project/jni/application/gemrb/src/core/ActorMgr.cpp b/project/jni/application/gemrb/gemrb/core/ActorMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ActorMgr.cpp rename to project/jni/application/gemrb/gemrb/core/ActorMgr.cpp diff --git a/project/jni/application/gemrb/src/core/ActorMgr.h b/project/jni/application/gemrb/gemrb/core/ActorMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/ActorMgr.h rename to project/jni/application/gemrb/gemrb/core/ActorMgr.h diff --git a/project/jni/application/gemrb/src/core/Ambient.cpp b/project/jni/application/gemrb/gemrb/core/Ambient.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Ambient.cpp rename to project/jni/application/gemrb/gemrb/core/Ambient.cpp diff --git a/project/jni/application/gemrb/src/core/Ambient.h b/project/jni/application/gemrb/gemrb/core/Ambient.h similarity index 100% rename from project/jni/application/gemrb/src/core/Ambient.h rename to project/jni/application/gemrb/gemrb/core/Ambient.h diff --git a/project/jni/application/gemrb/src/core/AmbientMgr.cpp b/project/jni/application/gemrb/gemrb/core/AmbientMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/AmbientMgr.cpp rename to project/jni/application/gemrb/gemrb/core/AmbientMgr.cpp diff --git a/project/jni/application/gemrb/src/core/AmbientMgr.h b/project/jni/application/gemrb/gemrb/core/AmbientMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/AmbientMgr.h rename to project/jni/application/gemrb/gemrb/core/AmbientMgr.h diff --git a/project/jni/application/gemrb/src/core/AnimStructures.h b/project/jni/application/gemrb/gemrb/core/AnimStructures.h similarity index 100% rename from project/jni/application/gemrb/src/core/AnimStructures.h rename to project/jni/application/gemrb/gemrb/core/AnimStructures.h diff --git a/project/jni/application/gemrb/src/core/Animation.cpp b/project/jni/application/gemrb/gemrb/core/Animation.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Animation.cpp rename to project/jni/application/gemrb/gemrb/core/Animation.cpp diff --git a/project/jni/application/gemrb/src/core/Animation.h b/project/jni/application/gemrb/gemrb/core/Animation.h similarity index 100% rename from project/jni/application/gemrb/src/core/Animation.h rename to project/jni/application/gemrb/gemrb/core/Animation.h diff --git a/project/jni/application/gemrb/src/core/AnimationFactory.cpp b/project/jni/application/gemrb/gemrb/core/AnimationFactory.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/AnimationFactory.cpp rename to project/jni/application/gemrb/gemrb/core/AnimationFactory.cpp diff --git a/project/jni/application/gemrb/src/core/AnimationFactory.h b/project/jni/application/gemrb/gemrb/core/AnimationFactory.h similarity index 100% rename from project/jni/application/gemrb/src/core/AnimationFactory.h rename to project/jni/application/gemrb/gemrb/core/AnimationFactory.h diff --git a/project/jni/application/gemrb/src/core/AnimationMgr.cpp b/project/jni/application/gemrb/gemrb/core/AnimationMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/AnimationMgr.cpp rename to project/jni/application/gemrb/gemrb/core/AnimationMgr.cpp diff --git a/project/jni/application/gemrb/src/core/AnimationMgr.h b/project/jni/application/gemrb/gemrb/core/AnimationMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/AnimationMgr.h rename to project/jni/application/gemrb/gemrb/core/AnimationMgr.h diff --git a/project/jni/application/gemrb/src/core/ArchiveImporter.cpp b/project/jni/application/gemrb/gemrb/core/ArchiveImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ArchiveImporter.cpp rename to project/jni/application/gemrb/gemrb/core/ArchiveImporter.cpp diff --git a/project/jni/application/gemrb/src/core/ArchiveImporter.h b/project/jni/application/gemrb/gemrb/core/ArchiveImporter.h similarity index 100% rename from project/jni/application/gemrb/src/core/ArchiveImporter.h rename to project/jni/application/gemrb/gemrb/core/ArchiveImporter.h diff --git a/project/jni/application/gemrb/src/core/Audio.cpp b/project/jni/application/gemrb/gemrb/core/Audio.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Audio.cpp rename to project/jni/application/gemrb/gemrb/core/Audio.cpp diff --git a/project/jni/application/gemrb/src/core/Audio.h b/project/jni/application/gemrb/gemrb/core/Audio.h similarity index 97% rename from project/jni/application/gemrb/src/core/Audio.h rename to project/jni/application/gemrb/gemrb/core/Audio.h index 640083160..af7e57766 100644 --- a/project/jni/application/gemrb/src/core/Audio.h +++ b/project/jni/application/gemrb/gemrb/core/Audio.h @@ -61,8 +61,8 @@ public: virtual void ResetMusics() = 0; virtual bool Play() = 0; virtual bool Stop() = 0; - virtual bool Pause() = 0; - virtual bool Resume() = 0; + virtual bool Pause() = 0; + virtual bool Resume() = 0; virtual int CreateStream(Holder) = 0; virtual void UpdateListenerPos(int XPos, int YPos ) = 0; virtual void GetListenerPos(int &XPos, int &YPos ) = 0; diff --git a/project/jni/application/gemrb/src/core/Bitmap.cpp b/project/jni/application/gemrb/gemrb/core/Bitmap.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Bitmap.cpp rename to project/jni/application/gemrb/gemrb/core/Bitmap.cpp diff --git a/project/jni/application/gemrb/src/core/Bitmap.h b/project/jni/application/gemrb/gemrb/core/Bitmap.h similarity index 100% rename from project/jni/application/gemrb/src/core/Bitmap.h rename to project/jni/application/gemrb/gemrb/core/Bitmap.h diff --git a/project/jni/application/gemrb/src/core/CMakeLists.txt b/project/jni/application/gemrb/gemrb/core/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/core/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/core/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/core/Cache.cpp b/project/jni/application/gemrb/gemrb/core/Cache.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Cache.cpp rename to project/jni/application/gemrb/gemrb/core/Cache.cpp diff --git a/project/jni/application/gemrb/src/core/Cache.h b/project/jni/application/gemrb/gemrb/core/Cache.h similarity index 100% rename from project/jni/application/gemrb/src/core/Cache.h rename to project/jni/application/gemrb/gemrb/core/Cache.h diff --git a/project/jni/application/gemrb/src/core/Calendar.cpp b/project/jni/application/gemrb/gemrb/core/Calendar.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Calendar.cpp rename to project/jni/application/gemrb/gemrb/core/Calendar.cpp diff --git a/project/jni/application/gemrb/src/core/Calendar.h b/project/jni/application/gemrb/gemrb/core/Calendar.h similarity index 100% rename from project/jni/application/gemrb/src/core/Calendar.h rename to project/jni/application/gemrb/gemrb/core/Calendar.h diff --git a/project/jni/application/gemrb/src/core/Callback.cpp b/project/jni/application/gemrb/gemrb/core/Callback.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Callback.cpp rename to project/jni/application/gemrb/gemrb/core/Callback.cpp diff --git a/project/jni/application/gemrb/src/core/Callback.h b/project/jni/application/gemrb/gemrb/core/Callback.h similarity index 100% rename from project/jni/application/gemrb/src/core/Callback.h rename to project/jni/application/gemrb/gemrb/core/Callback.h diff --git a/project/jni/application/gemrb/src/core/CharAnimations.cpp b/project/jni/application/gemrb/gemrb/core/CharAnimations.cpp similarity index 99% rename from project/jni/application/gemrb/src/core/CharAnimations.cpp rename to project/jni/application/gemrb/gemrb/core/CharAnimations.cpp index 979094834..7104db16f 100644 --- a/project/jni/application/gemrb/src/core/CharAnimations.cpp +++ b/project/jni/application/gemrb/gemrb/core/CharAnimations.cpp @@ -558,10 +558,12 @@ CharAnimations::CharAnimations(unsigned int AnimID, ieDword ArmourLevel) // make initial phase depend on location to make the pulse appear // less even ColorMods[i].phase = 5*i; + ColorMods[i].locked = false; } GlobalColorMod.type = RGBModifier::NONE; GlobalColorMod.speed = 0; GlobalColorMod.phase = 0; + GlobalColorMod.locked = false; lastModUpdate = 0; AvatarsRowNum=AvatarsCount; @@ -2338,6 +2340,7 @@ void CharAnimations::PulseRGBModifiers() GlobalColorMod.type = RGBModifier::NONE; GlobalColorMod.phase = 0; GlobalColorMod.speed = 0; + GlobalColorMod.locked = false; } } @@ -2347,6 +2350,12 @@ void CharAnimations::PulseRGBModifiers() { ColorMods[i].phase += inc; change[i>>3] = true; + if (ColorMods[i].phase > 2*ColorMods[i].speed) { + ColorMods[i].type = RGBModifier::NONE; + ColorMods[i].phase = 0; + ColorMods[i].speed = 0; + ColorMods[i].locked = false; + } } } diff --git a/project/jni/application/gemrb/src/core/CharAnimations.h b/project/jni/application/gemrb/gemrb/core/CharAnimations.h similarity index 100% rename from project/jni/application/gemrb/src/core/CharAnimations.h rename to project/jni/application/gemrb/gemrb/core/CharAnimations.h diff --git a/project/jni/application/gemrb/src/core/Compressor.cpp b/project/jni/application/gemrb/gemrb/core/Compressor.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Compressor.cpp rename to project/jni/application/gemrb/gemrb/core/Compressor.cpp diff --git a/project/jni/application/gemrb/src/core/Compressor.h b/project/jni/application/gemrb/gemrb/core/Compressor.h similarity index 100% rename from project/jni/application/gemrb/src/core/Compressor.h rename to project/jni/application/gemrb/gemrb/core/Compressor.h diff --git a/project/jni/application/gemrb/src/core/ControlAnimation.cpp b/project/jni/application/gemrb/gemrb/core/ControlAnimation.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ControlAnimation.cpp rename to project/jni/application/gemrb/gemrb/core/ControlAnimation.cpp diff --git a/project/jni/application/gemrb/src/core/ControlAnimation.h b/project/jni/application/gemrb/gemrb/core/ControlAnimation.h similarity index 100% rename from project/jni/application/gemrb/src/core/ControlAnimation.h rename to project/jni/application/gemrb/gemrb/core/ControlAnimation.h diff --git a/project/jni/application/gemrb/src/core/Core.cpp b/project/jni/application/gemrb/gemrb/core/Core.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Core.cpp rename to project/jni/application/gemrb/gemrb/core/Core.cpp diff --git a/project/jni/application/gemrb/src/core/DataFileMgr.cpp b/project/jni/application/gemrb/gemrb/core/DataFileMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/DataFileMgr.cpp rename to project/jni/application/gemrb/gemrb/core/DataFileMgr.cpp diff --git a/project/jni/application/gemrb/src/core/DataFileMgr.h b/project/jni/application/gemrb/gemrb/core/DataFileMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/DataFileMgr.h rename to project/jni/application/gemrb/gemrb/core/DataFileMgr.h diff --git a/project/jni/application/gemrb/src/core/Dialog.cpp b/project/jni/application/gemrb/gemrb/core/Dialog.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Dialog.cpp rename to project/jni/application/gemrb/gemrb/core/Dialog.cpp diff --git a/project/jni/application/gemrb/src/core/Dialog.h b/project/jni/application/gemrb/gemrb/core/Dialog.h similarity index 100% rename from project/jni/application/gemrb/src/core/Dialog.h rename to project/jni/application/gemrb/gemrb/core/Dialog.h diff --git a/project/jni/application/gemrb/src/core/DialogHandler.cpp b/project/jni/application/gemrb/gemrb/core/DialogHandler.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/DialogHandler.cpp rename to project/jni/application/gemrb/gemrb/core/DialogHandler.cpp diff --git a/project/jni/application/gemrb/src/core/DialogHandler.h b/project/jni/application/gemrb/gemrb/core/DialogHandler.h similarity index 100% rename from project/jni/application/gemrb/src/core/DialogHandler.h rename to project/jni/application/gemrb/gemrb/core/DialogHandler.h diff --git a/project/jni/application/gemrb/src/core/DialogMgr.cpp b/project/jni/application/gemrb/gemrb/core/DialogMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/DialogMgr.cpp rename to project/jni/application/gemrb/gemrb/core/DialogMgr.cpp diff --git a/project/jni/application/gemrb/src/core/DialogMgr.h b/project/jni/application/gemrb/gemrb/core/DialogMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/DialogMgr.h rename to project/jni/application/gemrb/gemrb/core/DialogMgr.h diff --git a/project/jni/application/gemrb/src/core/DisplayMessage.cpp b/project/jni/application/gemrb/gemrb/core/DisplayMessage.cpp similarity index 89% rename from project/jni/application/gemrb/src/core/DisplayMessage.cpp rename to project/jni/application/gemrb/gemrb/core/DisplayMessage.cpp index 1954acc3f..941391d52 100644 --- a/project/jni/application/gemrb/src/core/DisplayMessage.cpp +++ b/project/jni/application/gemrb/gemrb/core/DisplayMessage.cpp @@ -113,15 +113,17 @@ unsigned int DisplayMessage::GetSpeakerColor(const char *&name, const Scriptable void DisplayMessage::DisplayConstantString(int stridx, unsigned int color, Scriptable *target) const { if (stridx<0) return; - const char* text = core->GetString( strref_table[stridx], IE_STR_SOUND ); + char* text = core->GetString( strref_table[stridx], IE_STR_SOUND ); DisplayString(text, color, target); + core->FreeString(text); } void DisplayMessage::DisplayString(int stridx, unsigned int color, ieDword flags) const { if (stridx<0) return; - const char* text = core->GetString( stridx, flags); + char* text = core->GetString( stridx, flags); DisplayString(text, color, NULL); + core->FreeString(text); } void DisplayMessage::DisplayString(const char *text, unsigned int color, Scriptable *target) const @@ -179,10 +181,13 @@ void DisplayMessage::DisplayConstantStringName(int stridx, unsigned int color, c if (stridx<0) return; if(!speaker) return; - const char* text = core->GetString( strref_table[stridx], IE_STR_SOUND|IE_STR_SPEECH ); + char* text = core->GetString( strref_table[stridx], IE_STR_SOUND|IE_STR_SPEECH ); DisplayStringName(text, color, speaker); + core->FreeString(text); } +// String format is +// - blah blah void DisplayMessage::DisplayConstantStringAction(int stridx, unsigned int color, const Scriptable *attacker, const Scriptable *target) const { unsigned int attacker_color; @@ -209,8 +214,9 @@ void DisplayMessage::DisplayStringName(int stridx, unsigned int color, const Scr { if (stridx<0) return; - const char* text = core->GetString( stridx, flags); + char* text = core->GetString( stridx, flags); DisplayStringName(text, color, speaker); + core->FreeString( text ); } void DisplayMessage::DisplayStringName(const char *text, unsigned int color, const Scriptable *speaker) const @@ -221,10 +227,13 @@ void DisplayMessage::DisplayStringName(const char *text, unsigned int color, con if (!text) return; speaker_color = GetSpeakerColor(name, speaker); - int newlen = (int)(strlen( DisplayFormatName ) + strlen( name ) + - + strlen( text ) + 18); - char* newstr = ( char* ) malloc( newlen ); - snprintf( newstr, newlen, DisplayFormatName, speaker_color, name, color, text ); - DisplayString( newstr ); - free( newstr ); + //FIXME: what happens if there is no name? + if (name) { + int newlen = (int)(strlen( DisplayFormatName ) + strlen( name ) + + + strlen( text ) + 18); + char* newstr = ( char* ) malloc( newlen ); + snprintf( newstr, newlen, DisplayFormatName, speaker_color, name, color, text ); + DisplayString( newstr ); + free( newstr ); + } } diff --git a/project/jni/application/gemrb/src/core/DisplayMessage.h b/project/jni/application/gemrb/gemrb/core/DisplayMessage.h similarity index 100% rename from project/jni/application/gemrb/src/core/DisplayMessage.h rename to project/jni/application/gemrb/gemrb/core/DisplayMessage.h diff --git a/project/jni/application/gemrb/src/core/Effect.h b/project/jni/application/gemrb/gemrb/core/Effect.h similarity index 100% rename from project/jni/application/gemrb/src/core/Effect.h rename to project/jni/application/gemrb/gemrb/core/Effect.h diff --git a/project/jni/application/gemrb/src/core/EffectMgr.cpp b/project/jni/application/gemrb/gemrb/core/EffectMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/EffectMgr.cpp rename to project/jni/application/gemrb/gemrb/core/EffectMgr.cpp diff --git a/project/jni/application/gemrb/src/core/EffectMgr.h b/project/jni/application/gemrb/gemrb/core/EffectMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/EffectMgr.h rename to project/jni/application/gemrb/gemrb/core/EffectMgr.h diff --git a/project/jni/application/gemrb/src/core/EffectQueue.cpp b/project/jni/application/gemrb/gemrb/core/EffectQueue.cpp similarity index 99% rename from project/jni/application/gemrb/src/core/EffectQueue.cpp rename to project/jni/application/gemrb/gemrb/core/EffectQueue.cpp index 3828c85ad..b34f6dd52 100644 --- a/project/jni/application/gemrb/src/core/EffectQueue.cpp +++ b/project/jni/application/gemrb/gemrb/core/EffectQueue.cpp @@ -857,8 +857,7 @@ static int check_type(Actor* actor, Effect* fx) return 0; } if (actor->fxqueue.HasEffectWithResource(fx_store_spell_sequencer_ref, fx->Source) ) { - //TODO: display strref 0x806C - return 0; + return 0; } } diff --git a/project/jni/application/gemrb/src/core/EffectQueue.h b/project/jni/application/gemrb/gemrb/core/EffectQueue.h similarity index 100% rename from project/jni/application/gemrb/src/core/EffectQueue.h rename to project/jni/application/gemrb/gemrb/core/EffectQueue.h diff --git a/project/jni/application/gemrb/src/core/Factory.cpp b/project/jni/application/gemrb/gemrb/core/Factory.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Factory.cpp rename to project/jni/application/gemrb/gemrb/core/Factory.cpp diff --git a/project/jni/application/gemrb/src/core/Factory.h b/project/jni/application/gemrb/gemrb/core/Factory.h similarity index 100% rename from project/jni/application/gemrb/src/core/Factory.h rename to project/jni/application/gemrb/gemrb/core/Factory.h diff --git a/project/jni/application/gemrb/src/core/FactoryObject.cpp b/project/jni/application/gemrb/gemrb/core/FactoryObject.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/FactoryObject.cpp rename to project/jni/application/gemrb/gemrb/core/FactoryObject.cpp diff --git a/project/jni/application/gemrb/src/core/FactoryObject.h b/project/jni/application/gemrb/gemrb/core/FactoryObject.h similarity index 100% rename from project/jni/application/gemrb/src/core/FactoryObject.h rename to project/jni/application/gemrb/gemrb/core/FactoryObject.h diff --git a/project/jni/application/gemrb/src/core/Font.cpp b/project/jni/application/gemrb/gemrb/core/Font.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Font.cpp rename to project/jni/application/gemrb/gemrb/core/Font.cpp diff --git a/project/jni/application/gemrb/src/core/Font.h b/project/jni/application/gemrb/gemrb/core/Font.h similarity index 100% rename from project/jni/application/gemrb/src/core/Font.h rename to project/jni/application/gemrb/gemrb/core/Font.h diff --git a/project/jni/application/gemrb/src/core/GUI/Button.cpp b/project/jni/application/gemrb/gemrb/core/GUI/Button.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Button.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/Button.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/Button.h b/project/jni/application/gemrb/gemrb/core/GUI/Button.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Button.h rename to project/jni/application/gemrb/gemrb/core/GUI/Button.h diff --git a/project/jni/application/gemrb/src/core/GUI/Console.cpp b/project/jni/application/gemrb/gemrb/core/GUI/Console.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Console.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/Console.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/Console.h b/project/jni/application/gemrb/gemrb/core/GUI/Console.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Console.h rename to project/jni/application/gemrb/gemrb/core/GUI/Console.h diff --git a/project/jni/application/gemrb/src/core/GUI/Control.cpp b/project/jni/application/gemrb/gemrb/core/GUI/Control.cpp similarity index 98% rename from project/jni/application/gemrb/src/core/GUI/Control.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/Control.cpp index 74e2488d3..fc02eb9db 100644 --- a/project/jni/application/gemrb/src/core/GUI/Control.cpp +++ b/project/jni/application/gemrb/gemrb/core/GUI/Control.cpp @@ -125,8 +125,7 @@ void Control::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) { //printf("OnKeyPress: CtrlID = 0x%08X, Key = %c (0x%02hX)\n", (unsigned int) ControlID, Key, Key); #ifdef ANDROID // mapping volume control to volume control keys on device, these keys must be set up in AndroidAppSettings.cfg - switch(Key) - { + switch(Key) { case 'o': // volume down case 'p': // volume up int Ambients, Movie, Music, SFX, Voices; @@ -135,23 +134,20 @@ void Control::OnKeyPress(unsigned char Key, unsigned short /*Mod*/) core->GetDictionary()->Lookup( "Volume Music", (ieDword&)Music ); core->GetDictionary()->Lookup( "Volume SFX", (ieDword&)SFX ); core->GetDictionary()->Lookup( "Volume Voices", (ieDword&)Voices ); - if(Key=='o') - { + if (Key=='o') { if(Ambients>0) Ambients-=10; if(Ambients<0) Ambients=0; if(Movie>0) Movie-=10; if(Movie<0) Movie=0; if(Music>0) Music-=10; if(Music<0) Music=0; if(SFX>0) SFX-=10; if(SFX<0) SFX=0; if(Voices>0) Voices-=10; if(Voices<0) Voices=0; - } - else - { + } else { if(Ambients<100) Ambients+=10; if(Ambients>100) Ambients=100; if(Movie<100) Movie+=10; if(Movie>100) Movie=100; if(Music<100) Music+=10; if(Music>100) Music=100; if(SFX<100) SFX+=10; if(SFX>100) SFX=100; if(Voices<100) Voices+=10; if(Voices>100) Voices=100; } - core->GetDictionary()->SetAt( "Volume Ambients", (ieDword)Ambients ); + core->GetDictionary()->SetAt( "Volume Ambients", Ambients ); core->GetDictionary()->SetAt( "Volume Movie", Movie ); core->GetDictionary()->SetAt( "Volume Music", Music ); core->GetDictionary()->SetAt( "Volume SFX", SFX ); diff --git a/project/jni/application/gemrb/src/core/GUI/Control.h b/project/jni/application/gemrb/gemrb/core/GUI/Control.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Control.h rename to project/jni/application/gemrb/gemrb/core/GUI/Control.h diff --git a/project/jni/application/gemrb/src/core/GUI/EventMgr.cpp b/project/jni/application/gemrb/gemrb/core/GUI/EventMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/EventMgr.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/EventMgr.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/EventMgr.h b/project/jni/application/gemrb/gemrb/core/GUI/EventMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/EventMgr.h rename to project/jni/application/gemrb/gemrb/core/GUI/EventMgr.h diff --git a/project/jni/application/gemrb/src/core/GUI/GameControl.cpp b/project/jni/application/gemrb/gemrb/core/GUI/GameControl.cpp similarity index 92% rename from project/jni/application/gemrb/src/core/GUI/GameControl.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/GameControl.cpp index a907b6f49..4382281ed 100644 --- a/project/jni/application/gemrb/src/core/GUI/GameControl.cpp +++ b/project/jni/application/gemrb/gemrb/core/GUI/GameControl.cpp @@ -44,6 +44,12 @@ #define DEBUG_SHOW_DOORS DEBUG_SHOW_CONTAINERS #define DEBUG_SHOW_LIGHTMAP 0x08 +#ifndef TOUCHSCREEN + #define SCROLL_BORDER 5 +#else + #define SCROLL_BORDER 32 +#endif + static const Color cyan = { 0x00, 0xff, 0xff, 0xff }; @@ -68,6 +74,12 @@ static const Color blue = { 0x00, 0x00, 0xff, 0x80 }; +#ifdef TOUCHSCREEN +static const Color gray = { + 0x80, 0x80, 0x80, 0xff +}; +#endif + //Animation* effect; #define FORMATIONSIZE 10 @@ -120,6 +132,9 @@ GameControl::GameControl(void) lastCursor = IE_CURSOR_NORMAL; moveX = moveY = 0; scrolling = false; +#ifdef TOUCHSCREEN + touched=false; +#endif numScrollCursor = 0; DebugFlags = 0; AIUpdateCounter = 1; @@ -131,8 +146,7 @@ GameControl::GameControl(void) core->GetDictionary()->Lookup("Center",tmp); if (tmp) { ScreenFlags=SF_ALWAYSCENTER|SF_CENTERONACTOR; - } - else { + } else { ScreenFlags = SF_CENTERONACTOR; } LeftCount = 0; @@ -572,6 +586,25 @@ void GameControl::Draw(unsigned short x, unsigned short y) } } } + +#ifdef TOUCHSCREEN + if(moveY < 0 && scrolling) + video->DrawLine(screen.x+4, screen.y+SCROLL_BORDER, screen.w+screen.x-4, screen.y+SCROLL_BORDER, red); + else + video->DrawLine(screen.x+4, screen.y+SCROLL_BORDER, screen.w+screen.x-4, screen.y+SCROLL_BORDER, gray); + if(moveY > 0 && scrolling) + video->DrawLine(screen.x+4, screen.h-SCROLL_BORDER, screen.w+screen.x-4, screen.h-SCROLL_BORDER, red); + else + video->DrawLine(screen.x+4, screen.h-SCROLL_BORDER, screen.w+screen.x-4, screen.h-SCROLL_BORDER, gray); + if(moveX < 0 && scrolling) + video->DrawLine(screen.x+SCROLL_BORDER, screen.y+4, screen.x+SCROLL_BORDER, screen.h+screen.y-4, red); + else + video->DrawLine(screen.x+SCROLL_BORDER, screen.y+4, screen.x+SCROLL_BORDER, screen.h+screen.y-4, gray); + if(moveX > 0 && scrolling) + video->DrawLine(screen.w+screen.x-SCROLL_BORDER, screen.y+4, screen.w+screen.x-SCROLL_BORDER, screen.h-4, red); + else + video->DrawLine(screen.w+screen.x-SCROLL_BORDER, screen.y+4, screen.w+screen.x-SCROLL_BORDER, screen.h-4, gray); +#endif } /** inherited from Control, GameControl doesn't need it */ @@ -760,9 +793,9 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) if (target) { src->CastSpell( TestSpell, target, false ); if (src->LastTarget) { - src->CastSpellEnd( TestSpell ); + src->CastSpellEnd(); } else { - src->CastSpellPointEnd( TestSpell ); + src->CastSpellPointEnd(); } } } @@ -971,12 +1004,12 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod) printf("Show lightmap %s\n", DebugFlags & DEBUG_SHOW_LIGHTMAP ? "ON" : "OFF"); break; case '7': //toggles fog of war - core->FogOfWar ^= 1; - printf("Show Fog-Of-War: %s\n", core->FogOfWar & 1 ? "ON" : "OFF"); + core->FogOfWar ^= FOG_DRAWFOG; + printf("Show Fog-Of-War: %s\n", core->FogOfWar & FOG_DRAWFOG ? "ON" : "OFF"); break; case '8': //show searchmap over area - core->FogOfWar ^= 2; - printf("Show searchmap %s\n", core->FogOfWar & 2 ? "ON" : "OFF"); + core->FogOfWar ^= FOG_DRAWSEARCHMAP; + printf("Show searchmap %s\n", core->FogOfWar & FOG_DRAWSEARCHMAP ? "ON" : "OFF"); break; default: printf( "KeyRelease:%d - %d\n", Key, Mod ); @@ -1196,7 +1229,72 @@ void GameControl::OnMouseOver(unsigned short x, unsigned short y) if (ScreenFlags & SF_DISABLEMOUSE) { return; } + +#ifdef TOUCHSCREEN + int mousescrollspd = core->GetMouseScrollSpeed(); + Region region; + Map* map; + Point mapsize; + Region viewport = core->GetVideoDriver()->GetViewport(); + moveX = 0; + moveY = 0; + // Top scroll area + region=Region(XPos, YPos, Width, YPos+SCROLL_BORDER); + if(region.PointInside(x, y)) + { + // Check for end of map area + if(viewport.y > 0) + moveY = -mousescrollspd; + } + // Bottom scroll area + region=Region(XPos, Height-SCROLL_BORDER, Width, Height); + if(region.PointInside(x, y)) + { + // Check for end of map area + map = core->GetGame()->GetCurrentArea(); + if(map != NULL) + { + mapsize = map->TMap->GetMapSize(); + if((viewport.y + viewport.h) < mapsize.y) + moveY = mousescrollspd; + } + } + // Left scroll area + region=Region(XPos, YPos, XPos+SCROLL_BORDER, Height); + if(region.PointInside(x, y)) + { + // Check for end of map area + if(viewport.x > 0) + moveX = -mousescrollspd; + } + // Right scroll area + region=Region(Width-SCROLL_BORDER, YPos, Width, Height); + if(region.PointInside(x, y)) + { + // Check for end of map area + map = core->GetGame()->GetCurrentArea(); + if(map != NULL) + { + mapsize = map->TMap->GetMapSize(); + if((viewport.x + viewport.w) < mapsize.x) + moveX = mousescrollspd; + } + } + if ((moveX != 0 || moveY != 0) && touched) + { + scrolling = true; + return; + } + else + { + moveX = 0; + moveY = 0; + scrolling = false; + Video* video = core->GetVideoDriver(); + video->SetDragCursor(NULL); + } +#endif lastMouseX = x; lastMouseY = y; Point p( x,y ); @@ -1361,7 +1459,7 @@ end_function: } } -#define SCROLL_BORDER 5 +//#define SCROLL_BORDER 5 /** Global Mouse Move Event */ void GameControl::OnGlobalMouseMove(unsigned short x, unsigned short y) @@ -1373,7 +1471,7 @@ void GameControl::OnGlobalMouseMove(unsigned short x, unsigned short y) if (Owner->Visible!=WINDOW_VISIBLE) { return; } - +#ifndef TOUCHSCREEN int mousescrollspd = core->GetMouseScrollSpeed(); if (x <= SCROLL_BORDER) @@ -1401,6 +1499,7 @@ void GameControl::OnGlobalMouseMove(unsigned short x, unsigned short y) Video* video = core->GetVideoDriver(); video->SetDragCursor(NULL); } +#endif } void GameControl::UpdateScrolling() { @@ -1475,11 +1574,11 @@ void GameControl::TryToPick(Actor *source, Door *tgt) source->ClearActions(); source->SetModal(MS_NONE); if (tgt->Trapped && tgt->TrapDetected) { - snprintf(Tmp, sizeof(Tmp), "RemoveTraps(\"%s\")", tgt->GetScriptName() ); + strncpy(Tmp, "RemoveTraps([-1])", sizeof(Tmp) ); } else { - snprintf(Tmp, sizeof(Tmp), "PickLock(\"%s\")", tgt->GetScriptName() ); + strncpy(Tmp, "PickLock([-1])", sizeof(Tmp) ); } - source->AddAction( GenerateAction( Tmp ) ); + source->AddAction( GenerateActionDirect( Tmp, tgt ) ); } //generate action code for source actor to try to pick a lock/disable trap on a container @@ -1491,11 +1590,11 @@ void GameControl::TryToPick(Actor *source, Container *tgt) source->ClearActions(); source->SetModal(MS_NONE); if (tgt->Trapped && tgt->TrapDetected) { - snprintf(Tmp, sizeof(Tmp), "RemoveTraps(\"%s\")", tgt->GetScriptName() ); + strncpy(Tmp, "RemoveTraps([-1])", sizeof(Tmp) ); } else { - snprintf(Tmp, sizeof(Tmp), "PickLock(\"%s\")", tgt->GetScriptName() ); + strncpy(Tmp, "PickLock([-1])", sizeof(Tmp) ); } - source->AddAction( GenerateAction( Tmp ) ); + source->AddAction( GenerateActionDirect( Tmp, tgt ) ); } //generate action code for source actor to try to disable trap (only trap type active regions) @@ -1508,20 +1607,8 @@ void GameControl::TryToDisarm(Actor *source, InfoPoint *tgt) source->ClearPath(); source->ClearActions(); source->SetModal(MS_NONE); - snprintf(Tmp, sizeof(Tmp), "RemoveTraps(\"%s\")", tgt->GetScriptName() ); - source->AddAction( GenerateAction( Tmp ) ); -} - -//generate action code for source actor to try to force open lock on a door/container -void GameControl::TryToBash(Actor *source, Scriptable *tgt) -{ - char Tmp[40]; - - source->ClearPath(); - source->ClearActions(); - source->SetModal(MS_NONE); - snprintf(Tmp, sizeof(Tmp), "Attack(\"%s\")", tgt->GetScriptName() ); - source->AddAction( GenerateAction( Tmp ) ); + strncpy(Tmp, "RemoveTraps([-1])", sizeof(Tmp) ); + source->AddAction( GenerateActionDirect( Tmp, tgt ) ); } //generate action code for source actor to use item/cast spell on a point @@ -1538,29 +1625,33 @@ void GameControl::TryToCast(Actor *source, const Point &tgt) spellCount--; if (spellOrItem>=0) { - sprintf(Tmp, "NIDSpecial8()"); + if (spellIndex<0) { + strncpy(Tmp, "SpellPointNoDec(\"\",[0.0])", sizeof(Tmp) ); + } else { + strncpy(Tmp, "SpellPoint(\"\",[0.0])", sizeof(Tmp) ); + } } else { //using item on target - sprintf(Tmp, "NIDSpecial7()"); + strncpy(Tmp, "UseItemPoint(\"\",[0,0],0)", sizeof(Tmp) ); } Action* action = GenerateAction( Tmp ); action->pointParameter=tgt; - if (spellOrItem>=0) - { - CREMemorizedSpell *si; - //spell casting at target - si = source->spellbook.GetMemorizedSpell(spellOrItem, spellSlot, spellIndex); - if (!si) - { - ResetTargetMode(); - return; + if (spellOrItem>=0) { + if (spellIndex<0) { + sprintf(action->string0Parameter,"%.8s",spellName); + } else { + CREMemorizedSpell *si; + //spell casting at target + si = source->spellbook.GetMemorizedSpell(spellOrItem, spellSlot, spellIndex); + if (!si) { + ResetTargetMode(); + return; + } + sprintf(action->string0Parameter,"%.8s",si->SpellResRef); } - sprintf(action->string0Parameter,"%.8s",si->SpellResRef); - } - else - { - action->int0Parameter=spellSlot; - action->int1Parameter=spellIndex; + } else { + action->int0Parameter = spellSlot; + action->int1Parameter = spellIndex; } source->AddAction( action ); if (!spellCount) { @@ -1582,28 +1673,32 @@ void GameControl::TryToCast(Actor *source, Actor *tgt) spellCount--; if (spellOrItem>=0) { - sprintf(Tmp, "NIDSpecial6()"); + if (spellIndex<0) { + sprintf(Tmp, "NIDSpecial7()"); + } else { + sprintf(Tmp, "NIDSpecial6()"); + } } else { //using item on target sprintf(Tmp, "NIDSpecial5()"); } Action* action = GenerateActionDirect( Tmp, tgt); - if (spellOrItem>=0) - { - CREMemorizedSpell *si; - //spell casting at target - si = source->spellbook.GetMemorizedSpell(spellOrItem, spellSlot, spellIndex); - if (!si) - { - ResetTargetMode(); - return; + if (spellOrItem>=0) { + if (spellIndex<0) { + sprintf(action->string0Parameter,"%.8s",spellName); + } else { + CREMemorizedSpell *si; + //spell casting at target + si = source->spellbook.GetMemorizedSpell(spellOrItem, spellSlot, spellIndex); + if (!si) { + ResetTargetMode(); + return; + } + sprintf(action->string0Parameter,"%.8s",si->SpellResRef); } - sprintf(action->string0Parameter,"%.8s",si->SpellResRef); - } - else - { - action->int0Parameter=spellSlot; - action->int1Parameter=spellIndex; + } else { + action->int0Parameter = spellSlot; + action->int1Parameter = spellIndex; } source->AddAction( action ); if (!spellCount) { @@ -1718,7 +1813,7 @@ bool GameControl::HandleActiveRegion(InfoPoint *trap, Actor * actor, Point &p) switch(trap->Type) { case ST_TRAVEL: - actor->UseExit(true); + actor->UseExit(trap->GetGlobalID()); return false; case ST_TRIGGER: //the importer shouldn't load the script @@ -1788,6 +1883,9 @@ void GameControl::OnMouseDown(unsigned short x, unsigned short y, unsigned short StartY = py; SelectionRect.w = 0; SelectionRect.h = 0; +#ifdef TOUCHSCREEN + touched=true; +#endif } } @@ -1812,6 +1910,37 @@ void GameControl::OnMouseUp(unsigned short x, unsigned short y, unsigned short B Map* area = game->GetCurrentArea( ); if (!area) return; +#ifdef TOUCHSCREEN + touched=false; + if(scrolling) + { + moveX = 0; + moveY = 0; + scrolling=false; + Video* video = core->GetVideoDriver(); + video->SetDragCursor(NULL); + if (DrawSelectionRect) + { + Actor** ab; + unsigned int count = area->GetActorInRect( ab, SelectionRect,true ); + if (count != 0) + { + for (i = 0; i < highlighted.size(); i++) + highlighted[i]->SetOver( false ); + highlighted.clear(); + game->SelectActor( NULL, false, SELECT_NORMAL ); + for (i = 0; i < count; i++) + { + // FIXME: should call handler only once + game->SelectActor( ab[i], true, SELECT_NORMAL ); + } + } + free( ab ); + DrawSelectionRect = false; + } + return; + } +#endif if (DrawSelectionRect) { Actor** ab; unsigned int count = area->GetActorInRect( ab, SelectionRect,true ); @@ -1876,8 +2005,16 @@ void GameControl::OnMouseUp(unsigned short x, unsigned short y, unsigned short B return; } if (overInfoPoint) { - if (HandleActiveRegion(overInfoPoint, pc, p)) { - return; + if (overInfoPoint->Type==ST_TRAVEL) { + int i = game->selected.size(); + ieDword exitID = overInfoPoint->GetGlobalID(); + while(i--) { + game->selected[i]->UseExit(exitID); + } + } else { + if (HandleActiveRegion(overInfoPoint, pc, p)) { + return; + } } } @@ -2160,8 +2297,7 @@ void GameControl::OnSpecialKeyPress(unsigned char Key) if (ScreenFlags & SF_LOCKSCROLL) { moveX = 0; moveY = 0; - } - else { + } else { // override any existing viewport moves which may be in progress core->timer->SetMoveViewPort( Viewport.x, Viewport.y, 0, false ); // move it directly ourselves, since we might be paused @@ -2668,6 +2804,7 @@ Actor *GameControl::GetLastActor() //cnt is the number of different targets (usually 1) void GameControl::SetupItemUse(int slot, int header, Actor *u, int targettype, int cnt) { + memset(spellName, 0, sizeof(ieResRef)); spellOrItem = -1; spellUser = u; spellSlot = slot; @@ -2685,8 +2822,9 @@ void GameControl::SetupItemUse(int slot, int header, Actor *u, int targettype, i //u is the caster //target type is a bunch of GetActor flags that alter valid targets //cnt is the number of different targets (usually 1) -void GameControl::SetupCasting(int type, int level, int idx, Actor *u, int targettype, int cnt) +void GameControl::SetupCasting(ieResRef spellname, int type, int level, int idx, Actor *u, int targettype, int cnt) { + memcpy(spellName, spellname, sizeof(ieResRef)); spellOrItem = type; spellUser = u; spellSlot = level; diff --git a/project/jni/application/gemrb/src/core/GUI/GameControl.h b/project/jni/application/gemrb/gemrb/core/GUI/GameControl.h similarity index 96% rename from project/jni/application/gemrb/src/core/GUI/GameControl.h rename to project/jni/application/gemrb/gemrb/core/GUI/GameControl.h index 8faa5e5ad..8a4f845f2 100644 --- a/project/jni/application/gemrb/src/core/GUI/GameControl.h +++ b/project/jni/application/gemrb/gemrb/core/GUI/GameControl.h @@ -112,6 +112,9 @@ private: Region SelectionRect; short StartX, StartY; //int action; +#ifdef TOUCHSCREEN + bool touched; // true, if player touched screen (left button down and hold) +#endif public: Door* overDoor; Container* overContainer; @@ -187,6 +190,8 @@ private: Actor *user; //the user of item or spell public: DialogHandler *dialoghandler; + //the name of the spell to cast + ieResRef spellName; //using spell or item int spellOrItem; // -1 = item, otherwise the spell type //the user of spell or item @@ -201,7 +206,6 @@ public: int HideGUI(); int UnhideGUI(); void TryToAttack(Actor *source, Actor *target); - void TryToBash(Actor *source, Scriptable *tgt); void TryToCast(Actor *source, const Point &p); void TryToCast(Actor *source, Actor *target); void TryToDefend(Actor *source, Actor *target); @@ -245,7 +249,7 @@ public: /** Sets up targeting with spells or items */ void SetupItemUse(int slot, int header, Actor *actor, int targettype, int cnt); /** Page is the spell type + spell level info */ - void SetupCasting(int type, int level, int slot, Actor *actor, int targettype, int cnt); + void SetupCasting(ieResRef spellname, int type, int level, int slot, Actor *actor, int targettype, int cnt); bool SetEvent(int eventType, EventHandler handler); }; diff --git a/project/jni/application/gemrb/src/core/GUI/Label.cpp b/project/jni/application/gemrb/gemrb/core/GUI/Label.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Label.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/Label.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/Label.h b/project/jni/application/gemrb/gemrb/core/GUI/Label.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Label.h rename to project/jni/application/gemrb/gemrb/core/GUI/Label.h diff --git a/project/jni/application/gemrb/src/core/GUI/MapControl.cpp b/project/jni/application/gemrb/gemrb/core/GUI/MapControl.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/MapControl.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/MapControl.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/MapControl.h b/project/jni/application/gemrb/gemrb/core/GUI/MapControl.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/MapControl.h rename to project/jni/application/gemrb/gemrb/core/GUI/MapControl.h diff --git a/project/jni/application/gemrb/src/core/GUI/Progressbar.cpp b/project/jni/application/gemrb/gemrb/core/GUI/Progressbar.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Progressbar.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/Progressbar.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/Progressbar.h b/project/jni/application/gemrb/gemrb/core/GUI/Progressbar.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Progressbar.h rename to project/jni/application/gemrb/gemrb/core/GUI/Progressbar.h diff --git a/project/jni/application/gemrb/src/core/GUI/ScrollBar.cpp b/project/jni/application/gemrb/gemrb/core/GUI/ScrollBar.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/ScrollBar.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/ScrollBar.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/ScrollBar.h b/project/jni/application/gemrb/gemrb/core/GUI/ScrollBar.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/ScrollBar.h rename to project/jni/application/gemrb/gemrb/core/GUI/ScrollBar.h diff --git a/project/jni/application/gemrb/src/core/GUI/Slider.cpp b/project/jni/application/gemrb/gemrb/core/GUI/Slider.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Slider.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/Slider.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/Slider.h b/project/jni/application/gemrb/gemrb/core/GUI/Slider.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Slider.h rename to project/jni/application/gemrb/gemrb/core/GUI/Slider.h diff --git a/project/jni/application/gemrb/src/core/GUI/TextArea.cpp b/project/jni/application/gemrb/gemrb/core/GUI/TextArea.cpp similarity index 98% rename from project/jni/application/gemrb/src/core/GUI/TextArea.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/TextArea.cpp index 6f3d05d43..b19ad5770 100644 --- a/project/jni/application/gemrb/src/core/GUI/TextArea.cpp +++ b/project/jni/application/gemrb/gemrb/core/GUI/TextArea.cpp @@ -840,6 +840,27 @@ void TextArea::RedrawTextArea(const char* VariableName, unsigned int Sum) Changed = true; } +void TextArea::SelectText(const char *select) +{ + int i = lines.size(); + while(i--) { + if (!stricmp(lines[i], select) ) { + CurLine = i; + if (sb) { + ScrollBar* bar = ( ScrollBar* ) sb; + bar->SetPos( i ); + } else { + SetRow( i ); + } + RedrawTextArea( VarName, i); + CalcRowCount(); + Owner->Invalidate(); + core->RedrawAll(); + break; + } + } +} + const char* TextArea::QueryText() { if ( ValueCreatePalette( white, black ); } diff --git a/project/jni/application/gemrb/src/core/GUI/TextEdit.h b/project/jni/application/gemrb/gemrb/core/GUI/TextEdit.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/TextEdit.h rename to project/jni/application/gemrb/gemrb/core/GUI/TextEdit.h diff --git a/project/jni/application/gemrb/src/core/GUI/Window.cpp b/project/jni/application/gemrb/gemrb/core/GUI/Window.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Window.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/Window.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/Window.h b/project/jni/application/gemrb/gemrb/core/GUI/Window.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/Window.h rename to project/jni/application/gemrb/gemrb/core/GUI/Window.h diff --git a/project/jni/application/gemrb/src/core/GUI/WorldMapControl.cpp b/project/jni/application/gemrb/gemrb/core/GUI/WorldMapControl.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/WorldMapControl.cpp rename to project/jni/application/gemrb/gemrb/core/GUI/WorldMapControl.cpp diff --git a/project/jni/application/gemrb/src/core/GUI/WorldMapControl.h b/project/jni/application/gemrb/gemrb/core/GUI/WorldMapControl.h similarity index 100% rename from project/jni/application/gemrb/src/core/GUI/WorldMapControl.h rename to project/jni/application/gemrb/gemrb/core/GUI/WorldMapControl.h diff --git a/project/jni/application/gemrb/src/core/Game.cpp b/project/jni/application/gemrb/gemrb/core/Game.cpp similarity index 98% rename from project/jni/application/gemrb/src/core/Game.cpp rename to project/jni/application/gemrb/gemrb/core/Game.cpp index 59a218593..a5f706c10 100644 --- a/project/jni/application/gemrb/src/core/Game.cpp +++ b/project/jni/application/gemrb/gemrb/core/Game.cpp @@ -96,6 +96,8 @@ Game::Game(void) : Scriptable( ST_GLOBAL ) } interval = 1000/AI_UPDATE_TIME; + hasInfra = false; + familiarBlock = false; //FIXME:i'm not sure in this... NoInterrupt(); } @@ -365,6 +367,11 @@ void Game::InitActorPos(Actor *actor) unsigned int ip = (unsigned int) (actor->InParty-1); AutoTable start("start"); AutoTable strta("startpos"); + + if (!start || !strta) { + printMessage("Game","Game is missing character start data.\n",RED); + abort(); + } // 0 - single player, 1 - tutorial, 2 - expansion ieDword playmode = 0; core->GetDictionary()->Lookup( "PlayMode", playmode ); @@ -384,8 +391,11 @@ void Game::InitActorPos(Actor *actor) actor->Pos.y = actor->Destination.y = (short) atoi( strta->QueryField( strta->GetRowIndex(ypos), ip ) ); actor->SetOrientation( atoi( strta->QueryField( strta->GetRowIndex(rot), ip) ), false ); - strta.load("startare"); - strnlwrcpy(actor->Area, strta->QueryField( strta->GetRowIndex(area), 0 ), 8 ); + if (strta.load("startare")) { + strnlwrcpy(actor->Area, strta->QueryField( strta->GetRowIndex(area), 0 ), 8 ); + } else { + strnlwrcpy(actor->Area, CurrentArea, 8 ); + } } int Game::JoinParty(Actor* actor, int join) @@ -1076,6 +1086,7 @@ bool Game::EveryoneNearPoint(Map *area, const Point &p, int flags) const return false; } if (Distance(p,PCs[i])>MAX_TRAVELING_DISTANCE) { +printf("Actor %s is not near!\n", PCs[i]->LongName); return false; } } @@ -1814,3 +1825,12 @@ Actor *Game::GetActorByGlobalID(ieDword globalID) return GetGlobalActorByGlobalID(globalID); } +ieByte *Game::AllocateMazeData() +{ + if (mazedata) { + free(mazedata); + } + mazedata = (ieByte*)malloc(MAZE_DATA_SIZE); + return mazedata; +} + diff --git a/project/jni/application/gemrb/src/core/Game.h b/project/jni/application/gemrb/gemrb/core/Game.h similarity index 89% rename from project/jni/application/gemrb/src/core/Game.h rename to project/jni/application/gemrb/gemrb/core/Game.h index 1e4f9b9ea..edb356001 100644 --- a/project/jni/application/gemrb/src/core/Game.h +++ b/project/jni/application/gemrb/gemrb/core/Game.h @@ -157,6 +157,64 @@ struct GAMLocationEntry { Point Pos; }; +//pst maze data structures (TODO: create a separate class?) +struct maze_entry { + ieDword unknown00; + ieDword accessible; + ieDword valid; + ieDword trapped; + ieDword traptype; + ieWord walls; + ieDword unknown16; +}; + +struct maze_header { + ieDword maze_sizex, maze_sizey; + ieDword pos1x, pos1y; //nordom's position + ieDword pos2x, pos2y; //main hall position + ieDword pos3x, pos3y; //unknown + ieDword pos4x, pos4y; //unknown + ieDword trapcount; //based on map size + ieDword initialized; //set to 1 + ieDword unknown2c; //unknown + ieDword unknown30; //unknown +}; + +#define MAZE_ENTRY_SIZE sizeof(maze_entry) +#define MAZE_HEADER_SIZE sizeof(maze_header) +#define MAZE_MAX_DIM 8 +#define MAZE_ENTRY_COUNT (MAZE_MAX_DIM*MAZE_MAX_DIM) +#define MAZE_DATA_SIZE (MAZE_ENTRY_COUNT*MAZE_ENTRY_SIZE+MAZE_HEADER_SIZE) +#define MAZE_DATA_SIZE_HARDCODED 1720 + +//maze header indices +#define MH_POS1X 0 +#define MH_POS1Y 1 +#define MH_POS2X 2 +#define MH_POS2Y 3 +#define MH_POS3X 4 +#define MH_POS3Y 5 +#define MH_POS4X 6 +#define MH_POS4Y 7 +#define MH_TRAPCOUNT 8 +#define MH_INITED 9 +#define MH_UNKNOWN2C 10 +#define MH_UNKNOWN30 11 + +//maze entry indices +#define ME_0 0 +#define ME_VALID 1 +#define ME_ACCESSIBLE 2 +#define ME_TRAP 3 +#define ME_WALLS 4 +#define ME_16 5 + +//ME_WALL bitfields +#define WALL_EAST 1 +#define WALL_WEST 2 +#define WALL_NORTH 4 +#define WALL_SOUTH 8 + #define MAX_CRLEVEL 32 typedef int CRRow[MAX_CRLEVEL]; @@ -227,6 +285,7 @@ public: int event_timer; EventHandler event_handler; //like in Control bool hasInfra; + bool familiarBlock; private: /** reads the challenge rating table */ void LoadCRTable(); @@ -398,6 +457,8 @@ public: void RestParty(int checks, int dream, int hp); /** timestop effect initiated by actor */ void TimeStop(Actor *actor, ieDword end); + /** updates the infravision info */ + void Infravision(); /** gets the colour which should be applied over the game area, may return NULL */ const Color *GetGlobalTint() const; @@ -413,8 +474,8 @@ public: void DebugDump(); /** Finds an actor by global ID */ Actor *GetActorByGlobalID(ieDword objectID); - /** updates the infravision info */ - void Infravision(); + /** Allocates maze data */ + ieByte *AllocateMazeData(); private: bool DetermineStartPosType(const TableMgr *strta); ieResRef *GetDream(Map *area); diff --git a/project/jni/application/gemrb/src/core/GameData.cpp b/project/jni/application/gemrb/gemrb/core/GameData.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GameData.cpp rename to project/jni/application/gemrb/gemrb/core/GameData.cpp diff --git a/project/jni/application/gemrb/src/core/GameData.h b/project/jni/application/gemrb/gemrb/core/GameData.h similarity index 100% rename from project/jni/application/gemrb/src/core/GameData.h rename to project/jni/application/gemrb/gemrb/core/GameData.h diff --git a/project/jni/application/gemrb/src/core/GameScript/Actions.cpp b/project/jni/application/gemrb/gemrb/core/GameScript/Actions.cpp similarity index 98% rename from project/jni/application/gemrb/src/core/GameScript/Actions.cpp rename to project/jni/application/gemrb/gemrb/core/GameScript/Actions.cpp index 2a9284883..f6cb55b7e 100644 --- a/project/jni/application/gemrb/src/core/GameScript/Actions.cpp +++ b/project/jni/application/gemrb/gemrb/core/GameScript/Actions.cpp @@ -189,7 +189,7 @@ void GameScript::RealSetGlobalTimer(Scriptable* Sender, Action* parameters) ieDword mytime=core->GetGame()->RealTime; SetVariable( Sender, parameters->string0Parameter, - parameters->int0Parameter + mytime); + parameters->int0Parameter*AI_UPDATE_TIME + mytime); } void GameScript::ChangeAllegiance(Scriptable* Sender, Action* parameters) @@ -2038,6 +2038,40 @@ void GameScript::PlaySequence(Scriptable* Sender, Action* parameters) actor->SetStance( parameters->int0Parameter ); } +//same as PlaySequence, but the value comes from a variable +//ToDo: create a PlaySequenceCore in GSUtils +void GameScript::PlaySequenceGlobal(Scriptable* Sender, Action* parameters) +{ + Scriptable* tar; + ieDword value; + + value = (ieDword) CheckVariable( Sender, parameters->string0Parameter ); + + if (parameters->objects[1]) { + tar = GetActorFromObject( Sender, parameters->objects[1] ); + if (!tar) { + //could be an animation + AreaAnimation* anim = Sender->GetCurrentArea( )->GetAnimation( parameters->objects[1]->objectName); + if (anim) { + //set animation's cycle to value; + anim->sequence=value; + anim->frame=0; + //what else to be done??? + anim->InitAnimation(); + } + return; + } + + } else { + tar = Sender; + } + if (tar->Type != ST_ACTOR) { + return; + } + Actor* actor = ( Actor* ) tar; + actor->SetStance( value ); +} + void GameScript::SetDialogue(Scriptable* Sender, Action* parameters) { if (Sender->Type != ST_ACTOR) { @@ -2544,14 +2578,14 @@ void GameScript::Spell(Scriptable* Sender, Action* parameters) //if target was set, fire spell if (Sender->LastTarget) { - Sender->CastSpellEnd( spellres ); + Sender->CastSpellEnd(); Sender->ReleaseCurrentAction(); return; } //the target was converted to a point if(!Sender->LastTargetPos.isempty()) { - Sender->CastSpellPointEnd( spellres ); + Sender->CastSpellPointEnd(); Sender->ReleaseCurrentAction(); return; } @@ -2613,7 +2647,7 @@ void GameScript::SpellPoint(Scriptable* Sender, Action* parameters) //if target was set, fire spell if (!Sender->LastTargetPos.isempty()) { - Sender->CastSpellPointEnd( spellres ); + Sender->CastSpellPointEnd(); Sender->ReleaseCurrentAction(); return; } @@ -2654,18 +2688,22 @@ void GameScript::SpellNoDec(Scriptable* Sender, Action* parameters) if (!ResolveSpellName( spellres, parameters) ) { Sender->ReleaseCurrentAction(); return; + } else { + if (!Sender->SpellResRef[0]) { + Sender->SetSpellResRef(spellres); + } } //if target was set, fire spell if (Sender->LastTarget) { - Sender->CastSpellEnd( spellres ); + Sender->CastSpellEnd(); Sender->ReleaseCurrentAction(); return; } //the target was converted to a point if(!Sender->LastTargetPos.isempty()) { - Sender->CastSpellPointEnd( spellres ); + Sender->CastSpellPointEnd(); Sender->ReleaseCurrentAction(); return; } @@ -2707,11 +2745,15 @@ void GameScript::SpellPointNoDec(Scriptable* Sender, Action* parameters) if (!ResolveSpellName( spellres, parameters) ) { Sender->ReleaseCurrentAction(); return; + } else { + if (!Sender->SpellResRef[0]) { + Sender->SetSpellResRef(spellres); + } } //if target was set, fire spell if (!Sender->LastTargetPos.isempty()) { - Sender->CastSpellPointEnd( spellres ); + Sender->CastSpellPointEnd(); Sender->ReleaseCurrentAction(); return; } @@ -2745,18 +2787,22 @@ void GameScript::ForceSpell(Scriptable* Sender, Action* parameters) if (!ResolveSpellName( spellres, parameters) ) { Sender->ReleaseCurrentAction(); return; + } else { + if (!Sender->SpellResRef[0]) { + Sender->SetSpellResRef(spellres); + } } //if target was set, fire spell if (Sender->LastTarget) { - Sender->CastSpellEnd( spellres ); + Sender->CastSpellEnd(); Sender->ReleaseCurrentAction(); return; } //the target was converted to a point if(!Sender->LastTargetPos.isempty()) { - Sender->CastSpellPointEnd( spellres ); + Sender->CastSpellPointEnd(); Sender->ReleaseCurrentAction(); return; } @@ -2797,11 +2843,15 @@ void GameScript::ForceSpellPoint(Scriptable* Sender, Action* parameters) if (!ResolveSpellName( spellres, parameters) ) { Sender->ReleaseCurrentAction(); return; + } else { + if (!Sender->SpellResRef[0]) { + Sender->SetSpellResRef(spellres); + } } //if target was set, fire spell if (!Sender->LastTargetPos.isempty()) { - Sender->CastSpellPointEnd( spellres ); + Sender->CastSpellPointEnd(); Sender->ReleaseCurrentAction(); return; } @@ -2835,6 +2885,10 @@ void GameScript::ReallyForceSpell(Scriptable* Sender, Action* parameters) if (!ResolveSpellName( spellres, parameters) ) { Sender->ReleaseCurrentAction(); return; + } else { + if (!Sender->SpellResRef[0]) { + Sender->SetSpellResRef(spellres); + } } Scriptable* tar = GetActorFromObject( Sender, parameters->objects[1] ); @@ -2851,9 +2905,9 @@ void GameScript::ReallyForceSpell(Scriptable* Sender, Action* parameters) } Sender->CastSpell (spellres, tar, false, true); if (tar->Type==ST_ACTOR) { - Sender->CastSpellEnd(spellres); + Sender->CastSpellEnd(); } else { - Sender->CastSpellPointEnd(spellres); + Sender->CastSpellPointEnd(); } Sender->ReleaseCurrentAction(); } @@ -2869,6 +2923,10 @@ void GameScript::ReallyForceSpellPoint(Scriptable* Sender, Action* parameters) if (!ResolveSpellName( spellres, parameters) ) { Sender->ReleaseCurrentAction(); return; + } else { + if (!Sender->SpellResRef[0]) { + Sender->SetSpellResRef(spellres); + } } //Sender->LastTargetPos=parameters->pointParameter; @@ -2882,7 +2940,7 @@ void GameScript::ReallyForceSpellPoint(Scriptable* Sender, Action* parameters) actor->SetStance (IE_ANI_CONJURE); } Sender->CastSpellPoint (spellres, parameters->pointParameter, false, true); - Sender->CastSpellPointEnd(spellres); + Sender->CastSpellPointEnd(); Sender->ReleaseCurrentAction(); } @@ -2895,6 +2953,10 @@ void GameScript::ReallyForceSpellDead(Scriptable* Sender, Action* parameters) if (!ResolveSpellName( spellres, parameters) ) { Sender->ReleaseCurrentAction(); return; + } else { + if (!Sender->SpellResRef[0]) { + Sender->SetSpellResRef(spellres); + } } Scriptable* tar = GetActorFromObject( Sender, parameters->objects[1] ); @@ -2912,9 +2974,9 @@ void GameScript::ReallyForceSpellDead(Scriptable* Sender, Action* parameters) */ Sender->CastSpell (spellres, tar, false, true); if (tar->Type==ST_ACTOR) { - Sender->CastSpellEnd(spellres); + Sender->CastSpellEnd(); } else { - Sender->CastSpellPointEnd(spellres); + Sender->CastSpellPointEnd(); } Sender->ReleaseCurrentAction(); } @@ -3161,7 +3223,6 @@ void GameScript::JoinParty(Scriptable* Sender, Action* parameters) } } core->GetGame()->JoinParty( act, JP_JOIN ); - //core->GetGUIScriptEngine()->RunFunction( "GUICommonWindows", "UpdatePortraitWindow" ); } void GameScript::LeaveParty(Scriptable* Sender, Action* /*parameters*/) @@ -3171,7 +3232,6 @@ void GameScript::LeaveParty(Scriptable* Sender, Action* /*parameters*/) } Actor* act = ( Actor* ) Sender; core->GetGame()->LeaveParty( act ); - //core->GetGUIScriptEngine()->RunFunction( "GUICommonWindows", "UpdatePortraitWindow" ); } //HideCreature hides only the visuals of a creature @@ -4752,7 +4812,7 @@ void GameScript::Damage(Scriptable* Sender, Action* parameters) } else { damager=damagee; } - int damage = damagee->LuckyRoll( (parameters->int1Parameter>>12)&15, (parameters->int1Parameter>>4)&255, parameters->int1Parameter&15, 0, 1, damager); + int damage = damagee->LuckyRoll( (parameters->int1Parameter>>12)&15, (parameters->int1Parameter>>4)&255, parameters->int1Parameter&15, LR_DAMAGELUCK, damager); int type=MOD_ADDITIVE; switch(parameters->int0Parameter) { case 2: //raise @@ -5553,6 +5613,20 @@ void GameScript::SetMazeHarder(Scriptable* Sender, Action* /*parameters*/) } } +void GameScript::GenerateMaze(Scriptable* /*Sender*/, Action* /*parameters*/) +{ + core->SetEventFlag(EF_CREATEMAZE); +} + +void GameScript::FixEngineRoom(Scriptable* Sender, Action* /*parameters*/) +{ + int value = CheckVariable( Sender, "EnginInMaze","GLOBAL"); + if (value) { + SetVariable(Sender, "EnginInMaze", "GLOBAL", 0); + core->SetEventFlag(EF_CREATEMAZE); + } +} + void GameScript::StartRainNow(Scriptable* /*Sender*/, Action* /*parameters*/) { core->GetGame()->StartRainOrSnow( false, WB_RAIN|WB_LIGHTNING); diff --git a/project/jni/application/gemrb/src/core/GameScript/GSUtils.cpp b/project/jni/application/gemrb/gemrb/core/GameScript/GSUtils.cpp similarity index 99% rename from project/jni/application/gemrb/src/core/GameScript/GSUtils.cpp rename to project/jni/application/gemrb/gemrb/core/GameScript/GSUtils.cpp index f283c2d62..a6d653cd9 100644 --- a/project/jni/application/gemrb/src/core/GameScript/GSUtils.cpp +++ b/project/jni/application/gemrb/gemrb/core/GameScript/GSUtils.cpp @@ -64,8 +64,6 @@ int ExtraParametersCount = 0; int InDebug = 0; int happiness[3][20]; int RandomNumValue; -int *SkillStats=NULL; -int SkillCount=-1; // reaction modifiers (by reputation and charisma) int rmodrep[20]; int rmodchr[25]; @@ -73,20 +71,6 @@ Gem_Polygon **polygons; void InitScriptTables() { - //initializing the skill->stats conversion table - { - AutoTable tab("skillsta"); - if (tab) { - int rowcount = tab->GetRowCount(); - SkillCount = rowcount; - if (rowcount) { - SkillStats = (int *) malloc(rowcount * sizeof(int) ); - while(rowcount--) { - SkillStats[rowcount]=strtol(tab->QueryField(rowcount,0), NULL, 0); - } - } - } - } //initializing the happiness table { AutoTable tab("happy"); @@ -1182,19 +1166,6 @@ void AttackCore(Scriptable *Sender, Scriptable *target, int flags) //bool leftorright = (bool) ((attacksperround-attackcount)&1); bool leftorright = false; - - //will return false on any errors (eg, unusable weapon) - if (!actor->GetCombatDetails(tohit, leftorright, wi, header, hittingheader, Flags, DamageBonus, speed, CriticalBonus, style)) { - Sender->ReleaseCurrentAction(); - return; - } - - if (header) wi.range *= 10; - else wi.range = 0; - - if ( target->Type == ST_DOOR || target->Type == ST_CONTAINER) { - wi.range += 10; - } Actor *tar = NULL; ieDword targetID = 0; if (target->Type==ST_ACTOR) { @@ -1205,6 +1176,20 @@ void AttackCore(Scriptable *Sender, Scriptable *target, int flags) Sender->ReleaseCurrentAction(); return; } + + //will return false on any errors (eg, unusable weapon) + if (!actor->GetCombatDetails(tohit, leftorright, wi, header, hittingheader, Flags, DamageBonus, speed, CriticalBonus, style, tar)) { + actor->SetStance(IE_ANI_READY); + Sender->ReleaseCurrentAction(); + return; + } + + if (header) wi.range *= 10; + else wi.range = 0; + + if ( target->Type == ST_DOOR || target->Type == ST_CONTAINER) { + wi.range += 10; + } if (!(flags&AC_NO_SOUND) ) { if (actor->LastTarget != targetID) { //play attack sound for party members diff --git a/project/jni/application/gemrb/src/core/GameScript/GSUtils.h b/project/jni/application/gemrb/gemrb/core/GameScript/GSUtils.h similarity index 99% rename from project/jni/application/gemrb/src/core/GameScript/GSUtils.h rename to project/jni/application/gemrb/gemrb/core/GameScript/GSUtils.h index afe9b1ae5..9297ba792 100644 --- a/project/jni/application/gemrb/src/core/GameScript/GSUtils.h +++ b/project/jni/application/gemrb/gemrb/core/GameScript/GSUtils.h @@ -55,8 +55,6 @@ extern ieResRef *ObjectIDSTableNames; extern int ObjectFieldsCount; extern int ExtraParametersCount; extern int InDebug; -extern int *SkillStats; -extern int SkillCount; extern Gem_Polygon **polygons; #define MIC_INVALID -2 diff --git a/project/jni/application/gemrb/src/core/GameScript/GameScript.cpp b/project/jni/application/gemrb/gemrb/core/GameScript/GameScript.cpp similarity index 99% rename from project/jni/application/gemrb/src/core/GameScript/GameScript.cpp rename to project/jni/application/gemrb/gemrb/core/GameScript/GameScript.cpp index f7c900069..37fc21835 100644 --- a/project/jni/application/gemrb/src/core/GameScript/GameScript.cpp +++ b/project/jni/application/gemrb/gemrb/core/GameScript/GameScript.cpp @@ -572,6 +572,7 @@ static const ActionLink actionnames[] = { {"fillslot", GameScript::FillSlot, 0}, {"finalsave", GameScript::SaveGame, 0}, //synonym {"findtraps", GameScript::FindTraps, 0}, + {"fixengineroom", GameScript::FixEngineRoom, 0}, {"floatmessage", GameScript::DisplayStringHead, 0}, {"floatmessagefixed", GameScript::FloatMessageFixed, 0}, {"floatmessagefixedrnd", GameScript::FloatMessageFixedRnd, 0}, @@ -592,6 +593,7 @@ static const ActionLink actionnames[] = { {"formation", GameScript::Formation, AF_BLOCKING}, {"fullheal", GameScript::FullHeal, 0}, {"fullhealex", GameScript::FullHeal, 0}, //pst, not sure what's different + {"generatemodronmaze", GameScript::GenerateMaze, 0}, {"generatepartymember", GameScript::GeneratePartyMember, 0}, {"getitem", GameScript::GetItem, 0}, {"getstat", GameScript::GetStat, 0}, //gemrb specific @@ -698,8 +700,8 @@ static const ActionLink actionnames[] = { {"nidspecial4", GameScript::ProtectObject,AF_BLOCKING|AF_DIRECT|AF_ALIVE}, {"nidspecial5", GameScript::UseItem, AF_BLOCKING|AF_DIRECT|AF_ALIVE}, {"nidspecial6", GameScript::Spell, AF_BLOCKING|AF_DIRECT|AF_ALIVE}, - {"nidspecial7", GameScript::UseItemPoint, AF_BLOCKING|AF_ALIVE}, - {"nidspecial8", GameScript::SpellPoint, AF_BLOCKING|AF_ALIVE}, + {"nidspecial7", GameScript::SpellNoDec, AF_BLOCKING|AF_DIRECT|AF_ALIVE}, + //{"nidspecial8", GameScript::SpellPoint, AF_BLOCKING|AF_ALIVE}, //not needed {"nidspecial9", GameScript::ToggleDoor, AF_BLOCKING},//another internal hack, maybe we should use UseDoor instead {"noaction", GameScript::NoAction, 0}, {"opendoor", GameScript::OpenDoor,0}, @@ -715,6 +717,7 @@ static const ActionLink actionnames[] = { {"playerdialog", GameScript::PlayerDialogue,AF_BLOCKING}, {"playerdialogue", GameScript::PlayerDialogue,AF_BLOCKING}, {"playsequence", GameScript::PlaySequence, 0}, + {"playsequenceglobal", GameScript::PlaySequenceGlobal, 0}, //pst {"playsequencetimed", GameScript::PlaySequenceTimed, 0},//pst {"playsong", GameScript::StartSong, 0}, {"playsound", GameScript::PlaySound, 0}, @@ -1251,10 +1254,6 @@ void Targets::Clear() /** releasing global memory */ static void CleanupIEScript() { - if (SkillStats) - free(SkillStats); - SkillStats = NULL; - SkillCount = -1; if (ObjectIDSTableNames) free(ObjectIDSTableNames); ObjectIDSTableNames = NULL; diff --git a/project/jni/application/gemrb/src/core/GameScript/GameScript.h b/project/jni/application/gemrb/gemrb/core/GameScript/GameScript.h similarity index 99% rename from project/jni/application/gemrb/src/core/GameScript/GameScript.h rename to project/jni/application/gemrb/gemrb/core/GameScript/GameScript.h index e0654c2f4..e6dc3c1e5 100644 --- a/project/jni/application/gemrb/src/core/GameScript/GameScript.h +++ b/project/jni/application/gemrb/gemrb/core/GameScript/GameScript.h @@ -1095,6 +1095,7 @@ public: static void FakeEffectExpiryCheck(Scriptable* Sender, Action* parameters); static void FillSlot(Scriptable *Sender, Action* parameters); static void FindTraps(Scriptable* Sender, Action* parameters); + static void FixEngineRoom(Scriptable *Sender, Action* parameters); static void FloatMessageFixed(Scriptable* Sender, Action* parameters); static void FloatMessageFixedRnd(Scriptable* Sender, Action* parameters); static void FloatMessageRnd(Scriptable* Sender, Action* parameters); @@ -1113,6 +1114,7 @@ public: static void ForceUseContainer(Scriptable* Sender, Action* parameters); static void Formation(Scriptable* Sender, Action* parameters); static void FullHeal(Scriptable* Sender, Action* parameters); + static void GenerateMaze(Scriptable* Sender, Action* parameters); static void GeneratePartyMember(Scriptable* Sender, Action* parameters); static void GetItem(Scriptable* Sender, Action* parameters); static void GetStat(Scriptable* Sender, Action* parameters); @@ -1217,6 +1219,7 @@ public: static void PlayDeadInterruptable(Scriptable* Sender, Action* parameters); static void PlayerDialogue(Scriptable* Sender, Action* parameters); static void PlaySequence(Scriptable* Sender, Action* parameters); + static void PlaySequenceGlobal(Scriptable* Sender, Action* parameters); static void PlaySequenceTimed(Scriptable* Sender, Action* parameters); static void PlaySound(Scriptable* Sender, Action* parameters); static void PlaySoundNotRanged(Scriptable* Sender, Action* parameters); diff --git a/project/jni/application/gemrb/src/core/GameScript/Matching.cpp b/project/jni/application/gemrb/gemrb/core/GameScript/Matching.cpp similarity index 94% rename from project/jni/application/gemrb/src/core/GameScript/Matching.cpp rename to project/jni/application/gemrb/gemrb/core/GameScript/Matching.cpp index 4665a8a2f..f0ad5d186 100644 --- a/project/jni/application/gemrb/src/core/GameScript/Matching.cpp +++ b/project/jni/application/gemrb/gemrb/core/GameScript/Matching.cpp @@ -26,30 +26,15 @@ #include "Game.h" #include "TileMap.h" -/* return a Targets object with a single actor inside */ -inline static Targets* ReturnActorAsTarget(Actor *aC) +/* return a Targets object with a single scriptable inside */ +inline static Targets* ReturnScriptableAsTarget(Scriptable *sc) { - if (!aC) return NULL; + if (!sc) return NULL; Targets *tgts = new Targets(); - tgts->AddTarget(aC, 0, 0); + tgts->AddTarget(sc, 0, 0); return tgts; } -/*Actor *FindActorNearby(const char *name, Map *except, int ga_flags) -{ - Game *game = core->GetGame(); - size_t mc = game->GetLoadedMapCount(); - while(mc--) { - Map *map = game->GetMap(mc); - if (map==except) continue; - Actor * aC = map->GetActor(name, ga_flags); - if (aC) { - return aC; - } - } - return NULL; -}*/ - /* do IDS filtering: [PC], [ENEMY], etc */ inline static bool DoObjectIDSCheck(Object *oC, Actor *ac, bool *filtered) { for (int j = 0; j < ObjectIDSCount; j++) { @@ -162,18 +147,34 @@ static Targets* EvaluateObject(Map *map, Scriptable* Sender, Object* oC, int ga_ }*/ //return here because object name/IDS targeting are mutually exclusive - return ReturnActorAsTarget(aC); + return ReturnScriptableAsTarget(aC); } if (oC->objectFields[0]==-1) { // this is an internal hack, allowing us to pass actor ids around as objects Actor* aC = map->GetActorByGlobalID( (ieDword) oC->objectFields[1] ); - /* TODO: this hack will throw away an invalid target */ - /* Consider putting this in GetActorByGlobalID */ - if (aC && !aC->ValidTarget(ga_flags)) { - aC = NULL; + if (aC) { + if (!aC->ValidTarget(ga_flags)) { + return NULL; + } + return ReturnScriptableAsTarget(aC); } - return ReturnActorAsTarget(aC); + Door *door = map->GetDoorByGlobalID( (ieDword) oC->objectFields[1]); + if (door) { + return ReturnScriptableAsTarget(door); + } + + Container* cont = map->GetContainerByGlobalID((ieDword) oC->objectFields[1]); + if (cont) { + return ReturnScriptableAsTarget(cont); + } + + InfoPoint* trap = map->GetInfoPointByGlobalID((ieDword) oC->objectFields[1]); + if (trap) { + return ReturnScriptableAsTarget(trap); + } + + return NULL; } Targets *tgts = NULL; @@ -225,21 +226,6 @@ Targets* GetAllObjects(Map *map, Scriptable* Sender, Object* oC, int ga_flags) return tgts; } -/*Targets *GetAllObjectsNearby(Scriptable* Sender, Object* oC, int ga_flags) -{ - Game *game = core->GetGame(); - size_t mc = game->GetLoadedMapCount(); - while(mc--) { - Map *map = game->GetMap(mc); - if (map==Sender->GetCurrentArea()) continue; - Targets *tgts = GetAllObjects(map, Sender, oC, ga_flags); - if (tgts) { - return tgts; - } - } - return NULL; -}*/ - Targets *GetAllActors(Scriptable *Sender, int ga_flags) { Map *map = Sender->GetCurrentArea(); diff --git a/project/jni/application/gemrb/src/core/GameScript/Matching.h b/project/jni/application/gemrb/gemrb/core/GameScript/Matching.h similarity index 95% rename from project/jni/application/gemrb/src/core/GameScript/Matching.h rename to project/jni/application/gemrb/gemrb/core/GameScript/Matching.h index 6a6562191..a01fa2253 100644 --- a/project/jni/application/gemrb/src/core/GameScript/Matching.h +++ b/project/jni/application/gemrb/gemrb/core/GameScript/Matching.h @@ -24,7 +24,7 @@ #include "exports.h" -Targets* GetAllObjects(Map *map, Scriptable* Sender, Object* oC, int ga_flags); +GEM_EXPORT Targets* GetAllObjects(Map *map, Scriptable* Sender, Object* oC, int ga_flags); Targets* GetAllActors(Scriptable* Sender, int ga_flags); Scriptable* GetActorFromObject(Scriptable* Sender, Object* oC, int ga_flags = 0); Scriptable* GetStoredActorFromObject(Scriptable* Sender, Object* oC, int ga_flags = 0); diff --git a/project/jni/application/gemrb/src/core/GameScript/Objects.cpp b/project/jni/application/gemrb/gemrb/core/GameScript/Objects.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GameScript/Objects.cpp rename to project/jni/application/gemrb/gemrb/core/GameScript/Objects.cpp diff --git a/project/jni/application/gemrb/src/core/GameScript/Triggers.cpp b/project/jni/application/gemrb/gemrb/core/GameScript/Triggers.cpp similarity index 99% rename from project/jni/application/gemrb/src/core/GameScript/Triggers.cpp rename to project/jni/application/gemrb/gemrb/core/GameScript/Triggers.cpp index a780d818f..874845a94 100644 --- a/project/jni/application/gemrb/src/core/GameScript/Triggers.cpp +++ b/project/jni/application/gemrb/gemrb/core/GameScript/Triggers.cpp @@ -2258,9 +2258,6 @@ int GameScript::XPLT(Scriptable* Sender, Trigger* parameters) int GameScript::CheckSkill(Scriptable* Sender, Trigger* parameters) { - if (parameters->int1Parameter>=SkillCount) { - return 0; - } Scriptable* target = GetActorFromObject( Sender, parameters->objectParameter ); if (!target) { return 0; @@ -2269,7 +2266,9 @@ int GameScript::CheckSkill(Scriptable* Sender, Trigger* parameters) return 0; } Actor* actor = ( Actor* ) target; - if ((signed) actor->GetStat( SkillStats[parameters->int1Parameter] ) == parameters->int0Parameter) { + int sk = actor->GetSkill( parameters->int1Parameter ); + if (sk<0) return 0; + if ( sk == parameters->int0Parameter) { return 1; } return 0; @@ -2284,7 +2283,7 @@ int GameScript::CheckStat(Scriptable* Sender, Trigger* parameters) return 0; } Actor* actor = ( Actor* ) target; - if ((signed) actor->GetStat( parameters->int1Parameter ) == parameters->int0Parameter) { + if ( (signed) actor->GetStat( parameters->int1Parameter ) == parameters->int0Parameter) { return 1; } return 0; @@ -2292,15 +2291,14 @@ int GameScript::CheckStat(Scriptable* Sender, Trigger* parameters) int GameScript::CheckSkillGT(Scriptable* Sender, Trigger* parameters) { - if (parameters->int1Parameter>=SkillCount) { - return 0; - } Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter ); if (!tar || tar->Type != ST_ACTOR) { return 0; } Actor* actor = ( Actor* ) tar; - if ((signed) actor->GetStat( SkillStats[parameters->int1Parameter] ) > parameters->int0Parameter) { + int sk = actor->GetSkill( parameters->int1Parameter ); + if (sk<0) return 0; + if ( sk > parameters->int0Parameter) { return 1; } return 0; @@ -2313,7 +2311,7 @@ int GameScript::CheckStatGT(Scriptable* Sender, Trigger* parameters) return 0; } Actor* actor = ( Actor* ) tar; - if ((signed) actor->GetStat( parameters->int1Parameter ) > parameters->int0Parameter) { + if ( (signed) actor->GetStat( parameters->int1Parameter ) > parameters->int0Parameter) { return 1; } return 0; @@ -2321,15 +2319,14 @@ int GameScript::CheckStatGT(Scriptable* Sender, Trigger* parameters) int GameScript::CheckSkillLT(Scriptable* Sender, Trigger* parameters) { - if (parameters->int1Parameter>=SkillCount) { - return 0; - } Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter ); if (!tar || tar->Type != ST_ACTOR) { return 0; } Actor* actor = ( Actor* ) tar; - if ((signed) actor->GetStat( SkillStats[parameters->int1Parameter] ) < parameters->int0Parameter) { + int sk = actor->GetSkill( parameters->int1Parameter ); + if (sk<0) return 0; + if ( sk < parameters->int0Parameter) { return 1; } return 0; @@ -2342,7 +2339,7 @@ int GameScript::CheckStatLT(Scriptable* Sender, Trigger* parameters) return 0; } Actor* actor = ( Actor* ) tar; - if ((signed) actor->GetStat( parameters->int1Parameter ) < parameters->int0Parameter) { + if ( (signed) actor->GetStat( parameters->int1Parameter ) < parameters->int0Parameter) { return 1; } return 0; diff --git a/project/jni/application/gemrb/src/core/GlobalTimer.cpp b/project/jni/application/gemrb/gemrb/core/GlobalTimer.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/GlobalTimer.cpp rename to project/jni/application/gemrb/gemrb/core/GlobalTimer.cpp diff --git a/project/jni/application/gemrb/src/core/GlobalTimer.h b/project/jni/application/gemrb/gemrb/core/GlobalTimer.h similarity index 100% rename from project/jni/application/gemrb/src/core/GlobalTimer.h rename to project/jni/application/gemrb/gemrb/core/GlobalTimer.h diff --git a/project/jni/application/gemrb/src/core/Holder.h b/project/jni/application/gemrb/gemrb/core/Holder.h similarity index 100% rename from project/jni/application/gemrb/src/core/Holder.h rename to project/jni/application/gemrb/gemrb/core/Holder.h diff --git a/project/jni/application/gemrb/src/core/Image.cpp b/project/jni/application/gemrb/gemrb/core/Image.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Image.cpp rename to project/jni/application/gemrb/gemrb/core/Image.cpp diff --git a/project/jni/application/gemrb/src/core/Image.h b/project/jni/application/gemrb/gemrb/core/Image.h similarity index 100% rename from project/jni/application/gemrb/src/core/Image.h rename to project/jni/application/gemrb/gemrb/core/Image.h diff --git a/project/jni/application/gemrb/src/core/ImageFactory.cpp b/project/jni/application/gemrb/gemrb/core/ImageFactory.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ImageFactory.cpp rename to project/jni/application/gemrb/gemrb/core/ImageFactory.cpp diff --git a/project/jni/application/gemrb/src/core/ImageFactory.h b/project/jni/application/gemrb/gemrb/core/ImageFactory.h similarity index 100% rename from project/jni/application/gemrb/src/core/ImageFactory.h rename to project/jni/application/gemrb/gemrb/core/ImageFactory.h diff --git a/project/jni/application/gemrb/src/core/ImageMgr.cpp b/project/jni/application/gemrb/gemrb/core/ImageMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ImageMgr.cpp rename to project/jni/application/gemrb/gemrb/core/ImageMgr.cpp diff --git a/project/jni/application/gemrb/src/core/ImageMgr.h b/project/jni/application/gemrb/gemrb/core/ImageMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/ImageMgr.h rename to project/jni/application/gemrb/gemrb/core/ImageMgr.h diff --git a/project/jni/application/gemrb/src/core/ImageWriter.cpp b/project/jni/application/gemrb/gemrb/core/ImageWriter.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ImageWriter.cpp rename to project/jni/application/gemrb/gemrb/core/ImageWriter.cpp diff --git a/project/jni/application/gemrb/src/core/ImageWriter.h b/project/jni/application/gemrb/gemrb/core/ImageWriter.h similarity index 100% rename from project/jni/application/gemrb/src/core/ImageWriter.h rename to project/jni/application/gemrb/gemrb/core/ImageWriter.h diff --git a/project/jni/application/gemrb/src/core/IniSpawn.cpp b/project/jni/application/gemrb/gemrb/core/IniSpawn.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/IniSpawn.cpp rename to project/jni/application/gemrb/gemrb/core/IniSpawn.cpp diff --git a/project/jni/application/gemrb/src/core/IniSpawn.h b/project/jni/application/gemrb/gemrb/core/IniSpawn.h similarity index 100% rename from project/jni/application/gemrb/src/core/IniSpawn.h rename to project/jni/application/gemrb/gemrb/core/IniSpawn.h diff --git a/project/jni/application/gemrb/src/core/Interface.cpp b/project/jni/application/gemrb/gemrb/core/Interface.cpp similarity index 98% rename from project/jni/application/gemrb/src/core/Interface.cpp rename to project/jni/application/gemrb/gemrb/core/Interface.cpp index 70f9afa3f..ee7b52cec 100644 --- a/project/jni/application/gemrb/src/core/Interface.cpp +++ b/project/jni/application/gemrb/gemrb/core/Interface.cpp @@ -236,6 +236,8 @@ Interface::Interface(int iargc, char* iargv[]) ItemDial2Table = NULL; ItemTooltipTable = NULL; update_scripts = false; + SpecialSpellsCount = -1; + SpecialSpells = NULL; gamedata = new GameData(); } @@ -341,6 +343,11 @@ Interface::~Interface(void) reputationmod=NULL; } + if (SpecialSpells) { + free(SpecialSpells); + } + SurgeSpells.clear(); + PluginMgr::Get()->RunCleanup(); ReleaseMemoryActor(); @@ -577,6 +584,12 @@ void Interface::HandleEvents() guiscript->RunFunction( "MessageWindow", "GameExpansion", false ); return; } + + if (EventFlag&EF_CREATEMAZE) { + EventFlag&=~EF_CREATEMAZE; + guiscript->RunFunction( "Maze", "CreateMaze", false ); + return; + } } /* handle main loop events that might destroy or create windows @@ -640,7 +653,7 @@ bool GenerateAbilityTables() strmodex = (ieWordSigned *) malloc (101 * 4 * sizeof(ieWordSigned) ); if (!strmodex) return false; - intmod = (ieWordSigned *) malloc (tablesize * 3 * sizeof(ieWordSigned) ); + intmod = (ieWordSigned *) malloc (tablesize * 5 * sizeof(ieWordSigned) ); if (!intmod) return false; dexmod = (ieWordSigned *) malloc (tablesize * 3 * sizeof(ieWordSigned) ); @@ -698,7 +711,7 @@ bool Interface::ReadAbilityTables() //3rd ed doesn't have strmodex, but has a maximum of 40 if (!ret && (MaximumAbility<=25) ) return ret; - ret = ReadAbilityTable("intmod", intmod, 3, MaximumAbility + 1); + ret = ReadAbilityTable("intmod", intmod, 5, MaximumAbility + 1); if (!ret) return ret; ret = ReadAbilityTable("hpconbon", conmod, 5, MaximumAbility + 1); @@ -741,10 +754,73 @@ bool Interface::ReadGameTimeTable() return true; } +bool Interface::ReadSpecialSpells() +{ + int i; + bool result = true; + + AutoTable table("splspec"); + if (table) { + SpecialSpellsCount = table->GetRowCount(); + SpecialSpells = (SpellDescType *) malloc( sizeof(SpellDescType) * SpecialSpellsCount); + for (i=0;iGetRowName(i),8 ); + //if there are more flags, compose this value into a bitfield + SpecialSpells[i].value = atoi(table->QueryField(i,0) ); + } + } else { + result = false; + } + + table.load("wildmag"); + if (table) { + SurgeSpell ss; + for (i = 0; (unsigned)i < table->GetRowCount(); i++) { + strncpy(ss.spell, table->QueryField(i, 0), 8); + ss.message = strtol(table->QueryField(i, 1), NULL, 0); + // comment ignored + SurgeSpells.push_back(ss); + } + } else { + result = false; + } + + return result; +} + +int Interface::GetSpecialSpell(ieResRef resref) +{ + for (int i=0;iGetStat(IE_STATE_ID) & STATE_SILENCED ) { + if (!(sp&SP_SILENCE)) { + return 1; + } + } + + return 0; +} + bool Interface::ReadAuxItemTables() { int idx; - int table; bool flag = true; if (ItemExclTable) { @@ -753,7 +829,6 @@ bool Interface::ReadAuxItemTables() ItemExclTable = new Variables(); ItemExclTable->SetType(GEM_VARIABLES_INT); } - table = gamedata->LoadTable( "itemexcl" ); AutoTable aa; @@ -1756,6 +1831,14 @@ int Interface::Init() } printStatus( "OK", LIGHT_GREEN ); + ret = ReadSpecialSpells(); + printMessage( "Core", "Reading special spells table...", WHITE); + if (ret) { + printStatus( "OK", LIGHT_GREEN ); + } else { + printStatus( "NOT FOUND", YELLOW ); + } + ret = ReadAuxItemTables(); printMessage( "Core", "Reading item tables...", WHITE); if (!ret) { @@ -2399,6 +2482,7 @@ static const char *game_flags[GF_COUNT+1]={ "JournalHasSections", //56GF_JOURNAL_HAS_SECTIONS "CastingSounds", //57GF_CASTING_SOUNDS "EnhancedCastingSounds", //58GF_CASTING_SOUNDS2 + "ForceAreaScript", //59GF_FORCE_AREA_SCRIPT NULL //for our own safety, this marks the end of the pole }; @@ -5121,17 +5205,11 @@ int Interface::GetStrengthBonus(int column, int value, int ex) const return strmod[column*(MaximumAbility+1)+value]+strmodex[column*101+ex]; } -// we don't use the stuff maze yet -// IE: bonus skill points are ignored and the plain int mod used! +//The maze columns are used only in the maze spell, no need to restrict them further int Interface::GetIntelligenceBonus(int column, int value) const { - if (HasFeature(GF_3ED_RULES)) { - //learn spell, max spell level, max spell number on level, bonus skill points - if (column<0 || column>2) return -9999; - } else { - //learn spell, max spell level, max spell number on level, maze duration dice, maze duration dice size - if (column<0 || column>4) return -9999; - } + //learn spell, max spell level, max spell number on level, maze duration dice, maze duration dice size + if (column<0 || column>4) return -9999; return intmod[column*(MaximumAbility+1)+value]; } diff --git a/project/jni/application/gemrb/src/core/Interface.h b/project/jni/application/gemrb/gemrb/core/Interface.h similarity index 97% rename from project/jni/application/gemrb/src/core/Interface.h rename to project/jni/application/gemrb/gemrb/core/Interface.h index 3965efc37..06eb11b9b 100644 --- a/project/jni/application/gemrb/src/core/Interface.h +++ b/project/jni/application/gemrb/gemrb/core/Interface.h @@ -133,6 +133,18 @@ struct TimeStruct { unsigned int rounds_per_turn; }; +struct SpellDescType { + ieResRef resref; + ieStrRef value; +}; +#define SP_IDENTIFY 1 //any spell that cannot be cast from the menu +#define SP_SILENCE 2 //any spell that can be cast in silence + +struct SurgeSpell { + ieResRef spell; + ieStrRef message; +}; + class ItemList { public: ieResRef *ResRefs; @@ -188,6 +200,7 @@ public: #define EF_SELECTION 128 //selection changed #define EF_OPENSTORE 256 //open store window #define EF_EXPANSION 512 //upgrade game request +#define EF_CREATEMAZE 1024 //call the maze generator //autopause #define AP_UNUSABLE 0 @@ -332,6 +345,8 @@ private: char NextScript[64]; /** Function to call every main loop iteration */ EventHandler TickHook; + int SpecialSpellsCount; + SpellDescType *SpecialSpells; public: Holder strings; GlobalTimer * timer; @@ -359,6 +374,7 @@ public: std::multimap DamageInfoMap; std::vector ModalStates; TimeStruct Time; + std::vector SurgeSpells; public: Interface(int iargc, char *iargv[]); ~Interface(void); @@ -668,6 +684,10 @@ public: void StripLine(char * string, size_t size); /** Returns the DeathVarFormat of the day */ static const char *GetDeathVarFormat(); + int CheckSpecialSpell(ieResRef resref, Actor *actor); + int GetSpecialSpell(ieResRef resref); + int GetSpecialSpellsCount() { return SpecialSpellsCount; }; + SpellDescType *GetSpecialSpells() { return SpecialSpells; }; private: int LoadSprites(); bool LoadConfig(void); @@ -683,6 +703,7 @@ private: bool ReadDamageTypeTable(); bool ReadReputationModTable(); bool ReadGameTimeTable(); + bool ReadSpecialSpells(); bool ReadModalStates(); /** Reads table of area name mappings for WorldMap (PST only) */ bool ReadAreaAliasTable(const ieResRef name); diff --git a/project/jni/application/gemrb/src/core/Inventory.cpp b/project/jni/application/gemrb/gemrb/core/Inventory.cpp similarity index 99% rename from project/jni/application/gemrb/src/core/Inventory.cpp rename to project/jni/application/gemrb/gemrb/core/Inventory.cpp index b1bf807ec..1dcc638c6 100644 --- a/project/jni/application/gemrb/src/core/Inventory.cpp +++ b/project/jni/application/gemrb/gemrb/core/Inventory.cpp @@ -1020,6 +1020,9 @@ bool Inventory::EquipItem(unsigned int slot) if (item->Flags & IE_INV_ITEM_CURSED) { item->Flags|=IE_INV_ITEM_UNDROPPABLE; } + if (effect == SLOT_EFFECT_MISSILE) { + slot = FindRangedWeapon(); + } AddSlotEffects( slot ); } return true; diff --git a/project/jni/application/gemrb/src/core/Inventory.h b/project/jni/application/gemrb/gemrb/core/Inventory.h similarity index 100% rename from project/jni/application/gemrb/src/core/Inventory.h rename to project/jni/application/gemrb/gemrb/core/Inventory.h diff --git a/project/jni/application/gemrb/src/core/Item.cpp b/project/jni/application/gemrb/gemrb/core/Item.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Item.cpp rename to project/jni/application/gemrb/gemrb/core/Item.cpp diff --git a/project/jni/application/gemrb/src/core/Item.h b/project/jni/application/gemrb/gemrb/core/Item.h similarity index 100% rename from project/jni/application/gemrb/src/core/Item.h rename to project/jni/application/gemrb/gemrb/core/Item.h diff --git a/project/jni/application/gemrb/src/core/ItemMgr.cpp b/project/jni/application/gemrb/gemrb/core/ItemMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ItemMgr.cpp rename to project/jni/application/gemrb/gemrb/core/ItemMgr.cpp diff --git a/project/jni/application/gemrb/src/core/ItemMgr.h b/project/jni/application/gemrb/gemrb/core/ItemMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/ItemMgr.h rename to project/jni/application/gemrb/gemrb/core/ItemMgr.h diff --git a/project/jni/application/gemrb/src/core/LRUCache.cpp b/project/jni/application/gemrb/gemrb/core/LRUCache.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/LRUCache.cpp rename to project/jni/application/gemrb/gemrb/core/LRUCache.cpp diff --git a/project/jni/application/gemrb/src/core/LRUCache.h b/project/jni/application/gemrb/gemrb/core/LRUCache.h similarity index 100% rename from project/jni/application/gemrb/src/core/LRUCache.h rename to project/jni/application/gemrb/gemrb/core/LRUCache.h diff --git a/project/jni/application/gemrb/src/core/Makefile.am b/project/jni/application/gemrb/gemrb/core/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/core/Makefile.am rename to project/jni/application/gemrb/gemrb/core/Makefile.am diff --git a/project/jni/application/gemrb/src/core/Map.cpp b/project/jni/application/gemrb/gemrb/core/Map.cpp similarity index 98% rename from project/jni/application/gemrb/src/core/Map.cpp rename to project/jni/application/gemrb/gemrb/core/Map.cpp index c18fd49df..45e1dc9e8 100644 --- a/project/jni/application/gemrb/src/core/Map.cpp +++ b/project/jni/application/gemrb/gemrb/core/Map.cpp @@ -66,7 +66,7 @@ static Point **VisibilityMasks=NULL; static bool PathFinderInited = false; static Variables Spawns; static int LargeFog; -static TerrainSounds *terrainsounds; +static TerrainSounds *terrainsounds=NULL; static int tsndcount = -1; void ReleaseSpawnGroup(void *poi) @@ -81,11 +81,14 @@ void Map::ReleaseMemory() free(VisibilityMasks[i]); } free(VisibilityMasks); - VisibilityMasks=NULL; + VisibilityMasks = NULL; } - Spawns.RemoveAll(ReleaseSpawnGroup); PathFinderInited = false; + if (terrainsounds) { + delete [] terrainsounds; + terrainsounds = NULL; + } } inline static AnimationObjectType SelectObject(Actor *actor, int q, AreaAnimation *a, ScriptedAnimation *sca, Particles *spark, Projectile *pro) @@ -188,22 +191,26 @@ void InitSpawnGroups() void InitPathFinder() { PathFinderInited = true; + tsndcount = 0; AutoTable tm("pathfind"); - if (tm) { - const char* poi; - for (int i = 0; i < 16; i++) { - poi = tm->QueryField( 0, i ); - if (*poi != '*') - Passable[i] = atoi( poi ); - } - poi = tm->QueryField( 1, 0 ); - if (*poi != '*') - NormalCost = atoi( poi ); - poi = tm->QueryField( 1, 1 ); - if (*poi != '*') - AdditionalCost = atoi( poi ); + if (!tm) { + return; } + + const char* poi; + + for (int i = 0; i < 16; i++) { + poi = tm->QueryField( 0, i ); + if (*poi != '*') + Passable[i] = atoi( poi ); + } + poi = tm->QueryField( 1, 0 ); + if (*poi != '*') + NormalCost = atoi( poi ); + poi = tm->QueryField( 1, 1 ); + if (*poi != '*') + AdditionalCost = atoi( poi ); int rc = tm->GetRowCount()-2; if (rc>0) { terrainsounds = new TerrainSounds[rc]; @@ -292,7 +299,6 @@ Map::Map(void) area=this; TMap = NULL; LightMap = NULL; - SearchMap = NULL; HeightMap = NULL; SmallMap = NULL; MapSet = NULL; @@ -351,7 +357,6 @@ Map::~Map(void) delete spawns[i]; } delete LightMap; - delete SearchMap; delete HeightMap; core->GetVideoDriver()->FreeSprite( SmallMap ); for (i = 0; i < QUEUE_COUNT; i++) { @@ -412,7 +417,6 @@ void Map::AddTileMap(TileMap* tm, Image* lm, Bitmap* sr, Sprite2D* sm, Bitmap* h // CHECKME: leaks? Should the old TMap, LightMap, etc... be freed? TMap = tm; LightMap = lm; - SearchMap = sr; HeightMap = hm; SmallMap = sm; Width = (unsigned int) (TMap->XCellCount * 4); @@ -420,13 +424,12 @@ void Map::AddTileMap(TileMap* tm, Image* lm, Bitmap* sr, Sprite2D* sm, Bitmap* h //Filling Matrices MapSet = (unsigned short *) malloc(sizeof(unsigned short) * Width * Height); //Internal Searchmap - int y = SearchMap->GetHeight(); - //smWidth = SearchMap->GetWidth(); - SrchMap = (unsigned short *) malloc(sizeof(unsigned short) * Width * y); + int y = sr->GetHeight(); + SrchMap = (unsigned short *) calloc(Width * Height, sizeof(unsigned short)); while(y--) { - int x=SearchMap->GetWidth(); + int x=sr->GetWidth(); while(x--) { - SrchMap[y*Width+x] = Passable[SearchMap->GetAt(x,y)&PATH_MAP_AREAMASK]; + SrchMap[y*Width+x] = Passable[sr->GetAt(x,y)&PATH_MAP_AREAMASK]; } } } @@ -499,6 +502,7 @@ void Map::MoveToNewArea(const char *area, const char *entrance, unsigned int dir while (i--) { Actor *pc = game->GetPC(i,false); if (pc->GetCurrentArea()==this) { + pc->UseExit(0); pc->ClearPath(); pc->ClearActions(); pc->AddAction( GenerateAction( command ) ); @@ -516,6 +520,7 @@ void Map::MoveToNewArea(const char *area, const char *entrance, unsigned int dir continue; } if (pc->GetCurrentArea()==this) { + pc->UseExit(0); pc->ClearPath(); pc->ClearActions(); pc->AddAction( GenerateAction( command ) ); @@ -550,9 +555,9 @@ void Map::UseExit(Actor *actor, InfoPoint *ip) break; } - actor->UseExit(false); if (ip->Destination[0] != 0) { - // 0 here is direction, can infopoints specify that or is an entrance always provided? + // the 0 here is default orientation, can infopoints specify that or + // is an entrance always provided? MoveToNewArea(ip->Destination, ip->EntranceName, 0, EveryOne, actor); return; } @@ -656,7 +661,7 @@ void Map::UpdateScripts() //if the actor is immobile, don't run the scripts if (!game->StateOverrideFlag && !game->StateOverrideTime) { - if (actor->Immobile()) { + if (actor->Immobile() || actor->GetStat(IE_STATE_ID) & STATE_SLEEP) { actor->no_more_steps = true; continue; } @@ -802,6 +807,7 @@ void Map::UpdateScripts() if (wasActive) { q=Qcount[PR_SCRIPT]; + ieDword exitID = ip->GetGlobalID(); while (q--) { Actor* actor = queue[PR_SCRIPT][q]; if (ip->Type == ST_PROXIMITY) { @@ -813,7 +819,7 @@ void Map::UpdateScripts() //ST_TRAVEL //don't move if doing something else // added CurrentAction as part of blocking action fixes - if (actor->CannotPassEntrance() ) { + if (actor->CannotPassEntrance(exitID) ) { continue; } //this is needed, otherwise the travel @@ -837,7 +843,7 @@ void Map::UpdateScripts() void Map::ResolveTerrainSound(ieResRef &sound, Point &Pos) { for(int i=0;iGetAt( Pos.x/16, Pos.y/12 )&PATH_MAP_AREAMASK; + int type = GetInternalSearchMap( Pos.x/16, Pos.y/12 )&PATH_MAP_AREAMASK; memcpy(sound, terrainsounds[i].Sounds[type], sizeof(ieResRef) ); return; } @@ -1138,7 +1144,7 @@ void Map::DrawMap(Region screen) } } - if ((core->FogOfWar&FOG_DRAWSEARCHMAP) && SearchMap) { + if ((core->FogOfWar&FOG_DRAWSEARCHMAP) && SrchMap) { DrawSearchMap(screen); } else { if ((core->FogOfWar&FOG_DRAWFOG) && TMap) { @@ -1719,7 +1725,7 @@ void Map::PlayAreaSong(int SongType, bool restart, bool hard) unsigned int Map::GetBlocked(unsigned int x, unsigned int y) { - if (y>Height || x>Width) { + if (y>=Height || x>=Width) { return 0; } unsigned int ret = SrchMap[y*Width+x]; @@ -2049,7 +2055,6 @@ void Map::RemoveActor(Actor* actor) size_t i=actors.size(); while (i--) { if (actors[i] == actor) { - //BlockSearchMap(actor->Pos, actor->size, PATH_MAP_FREE); ClearSearchMapFor(actor); actors.erase( actors.begin()+i ); return; @@ -3039,18 +3044,21 @@ void Map::UpdateFog() { if (!(core->FogOfWar&FOG_DRAWFOG) ) { SetMapVisibility( -1 ); - return; + Explore(-1); + } else { + SetMapVisibility( 0 ); } - SetMapVisibility( 0 ); for (unsigned int e = 0; eModified[ IE_EXPLORE ] ) continue; - int state = actor->Modified[IE_STATE_ID]; - if (state & STATE_CANTSEE) continue; - int vis2 = actor->Modified[IE_VISUALRANGE]; - if ((state&STATE_BLIND) || (vis2<2)) vis2=2; //can see only themselves - ExploreMapChunk (actor->Pos, vis2+actor->GetAnims()->GetCircleSize(), 1); + if (core->FogOfWar&FOG_DRAWFOG) { + int state = actor->Modified[IE_STATE_ID]; + if (state & STATE_CANTSEE) continue; + int vis2 = actor->Modified[IE_VISUALRANGE]; + if ((state&STATE_BLIND) || (vis2<2)) vis2=2; //can see only themselves + ExploreMapChunk (actor->Pos, vis2+actor->GetAnims()->GetCircleSize(), 1); + } Spawn *sp = GetSpawnRadius(actor->Pos, SPAWN_RANGE); //30 * 12 if (sp) { TriggerSpawn(sp); @@ -3085,29 +3093,21 @@ void Map::BlockSearchMap(const Point &Pos, unsigned int size, unsigned int value if ((ppxpiGetAt(ppx+i,ppy+j)&PATH_MAP_NOTACTOR; - //SearchMap->SetAt(ppx+i,ppy+j,tmp|value); } if ((ppxpiGetAt(ppx+i,ppy-j)&PATH_MAP_NOTACTOR; - //SearchMap->SetAt(ppx+i,ppy-j,tmp|value); } if ((ppxmiGetAt(ppx-i,ppy+j)&PATH_MAP_NOTACTOR; - //SearchMap->SetAt(ppx-i,ppy+j,tmp|value); } if ((ppxmiGetAt(ppx-i,ppy-j)&PATH_MAP_NOTACTOR; - //SearchMap->SetAt(ppx-i,ppy-j,tmp|value); } } } @@ -3615,3 +3615,17 @@ void Map::SeeSpellCast(Scriptable *caster, ieDword spell) } } } + +short unsigned int Map::GetInternalSearchMap(int x, int y) { + if ((unsigned)x >= Width || (unsigned)y >= Height) { + return 0; + } + return SrchMap[x+y*Width]; +} + +void Map::SetInternalSearchMap(int x, int y, int value) { + if ((unsigned)x >= Width || (unsigned)y >= Height) { + return; + } + SrchMap[x+y*Width] = value; +} diff --git a/project/jni/application/gemrb/src/core/Map.h b/project/jni/application/gemrb/gemrb/core/Map.h similarity index 99% rename from project/jni/application/gemrb/src/core/Map.h rename to project/jni/application/gemrb/gemrb/core/Map.h index d6df6c787..bf9cce508 100644 --- a/project/jni/application/gemrb/src/core/Map.h +++ b/project/jni/application/gemrb/gemrb/core/Map.h @@ -229,7 +229,6 @@ class GEM_EXPORT Map : public Scriptable { public: TileMap* TMap; Image* LightMap; - Bitmap* SearchMap; Bitmap* HeightMap; Sprite2D* SmallMap; IniSpawn *INISpawn; @@ -469,6 +468,8 @@ public: //returns true if tracking failed bool DisplayTrackString(Actor *actor); unsigned int GetLightLevel(const Point &Pos); + unsigned short GetInternalSearchMap(int x, int y); + void SetInternalSearchMap(int x, int y, int value); private: AreaAnimation *GetNextAreaAnimation(aniIterator &iter, ieDword gametime); Particles *GetNextSpark(spaIterator &iter); diff --git a/project/jni/application/gemrb/src/core/MapMgr.cpp b/project/jni/application/gemrb/gemrb/core/MapMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/MapMgr.cpp rename to project/jni/application/gemrb/gemrb/core/MapMgr.cpp diff --git a/project/jni/application/gemrb/src/core/MapMgr.h b/project/jni/application/gemrb/gemrb/core/MapMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/MapMgr.h rename to project/jni/application/gemrb/gemrb/core/MapMgr.h diff --git a/project/jni/application/gemrb/src/core/MoviePlayer.cpp b/project/jni/application/gemrb/gemrb/core/MoviePlayer.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/MoviePlayer.cpp rename to project/jni/application/gemrb/gemrb/core/MoviePlayer.cpp diff --git a/project/jni/application/gemrb/src/core/MoviePlayer.h b/project/jni/application/gemrb/gemrb/core/MoviePlayer.h similarity index 100% rename from project/jni/application/gemrb/src/core/MoviePlayer.h rename to project/jni/application/gemrb/gemrb/core/MoviePlayer.h diff --git a/project/jni/application/gemrb/src/core/MusicMgr.cpp b/project/jni/application/gemrb/gemrb/core/MusicMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/MusicMgr.cpp rename to project/jni/application/gemrb/gemrb/core/MusicMgr.cpp diff --git a/project/jni/application/gemrb/src/core/MusicMgr.h b/project/jni/application/gemrb/gemrb/core/MusicMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/MusicMgr.h rename to project/jni/application/gemrb/gemrb/core/MusicMgr.h diff --git a/project/jni/application/gemrb/src/core/Palette.cpp b/project/jni/application/gemrb/gemrb/core/Palette.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Palette.cpp rename to project/jni/application/gemrb/gemrb/core/Palette.cpp diff --git a/project/jni/application/gemrb/src/core/Palette.h b/project/jni/application/gemrb/gemrb/core/Palette.h similarity index 99% rename from project/jni/application/gemrb/src/core/Palette.h rename to project/jni/application/gemrb/gemrb/core/Palette.h index ed3df4d7e..14d53bb2c 100644 --- a/project/jni/application/gemrb/src/core/Palette.h +++ b/project/jni/application/gemrb/gemrb/core/Palette.h @@ -43,6 +43,7 @@ struct RGBModifier { TINT, BRIGHTEN } type; + bool locked; }; diff --git a/project/jni/application/gemrb/src/core/PalettedImageMgr.cpp b/project/jni/application/gemrb/gemrb/core/PalettedImageMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/PalettedImageMgr.cpp rename to project/jni/application/gemrb/gemrb/core/PalettedImageMgr.cpp diff --git a/project/jni/application/gemrb/src/core/PalettedImageMgr.h b/project/jni/application/gemrb/gemrb/core/PalettedImageMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/PalettedImageMgr.h rename to project/jni/application/gemrb/gemrb/core/PalettedImageMgr.h diff --git a/project/jni/application/gemrb/src/core/Particles.cpp b/project/jni/application/gemrb/gemrb/core/Particles.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Particles.cpp rename to project/jni/application/gemrb/gemrb/core/Particles.cpp diff --git a/project/jni/application/gemrb/src/core/Particles.h b/project/jni/application/gemrb/gemrb/core/Particles.h similarity index 100% rename from project/jni/application/gemrb/src/core/Particles.h rename to project/jni/application/gemrb/gemrb/core/Particles.h diff --git a/project/jni/application/gemrb/src/core/PathFinder.h b/project/jni/application/gemrb/gemrb/core/PathFinder.h similarity index 100% rename from project/jni/application/gemrb/src/core/PathFinder.h rename to project/jni/application/gemrb/gemrb/core/PathFinder.h diff --git a/project/jni/application/gemrb/src/core/Plugin.cpp b/project/jni/application/gemrb/gemrb/core/Plugin.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Plugin.cpp rename to project/jni/application/gemrb/gemrb/core/Plugin.cpp diff --git a/project/jni/application/gemrb/src/core/Plugin.h b/project/jni/application/gemrb/gemrb/core/Plugin.h similarity index 100% rename from project/jni/application/gemrb/src/core/Plugin.h rename to project/jni/application/gemrb/gemrb/core/Plugin.h diff --git a/project/jni/application/gemrb/src/core/PluginMgr.cpp b/project/jni/application/gemrb/gemrb/core/PluginMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/PluginMgr.cpp rename to project/jni/application/gemrb/gemrb/core/PluginMgr.cpp diff --git a/project/jni/application/gemrb/src/core/PluginMgr.h b/project/jni/application/gemrb/gemrb/core/PluginMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/PluginMgr.h rename to project/jni/application/gemrb/gemrb/core/PluginMgr.h diff --git a/project/jni/application/gemrb/src/core/Polygon.cpp b/project/jni/application/gemrb/gemrb/core/Polygon.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Polygon.cpp rename to project/jni/application/gemrb/gemrb/core/Polygon.cpp diff --git a/project/jni/application/gemrb/src/core/Polygon.h b/project/jni/application/gemrb/gemrb/core/Polygon.h similarity index 100% rename from project/jni/application/gemrb/src/core/Polygon.h rename to project/jni/application/gemrb/gemrb/core/Polygon.h diff --git a/project/jni/application/gemrb/src/core/PolymorphCache.h b/project/jni/application/gemrb/gemrb/core/PolymorphCache.h similarity index 100% rename from project/jni/application/gemrb/src/core/PolymorphCache.h rename to project/jni/application/gemrb/gemrb/core/PolymorphCache.h diff --git a/project/jni/application/gemrb/src/core/Projectile.cpp b/project/jni/application/gemrb/gemrb/core/Projectile.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Projectile.cpp rename to project/jni/application/gemrb/gemrb/core/Projectile.cpp diff --git a/project/jni/application/gemrb/src/core/Projectile.h b/project/jni/application/gemrb/gemrb/core/Projectile.h similarity index 100% rename from project/jni/application/gemrb/src/core/Projectile.h rename to project/jni/application/gemrb/gemrb/core/Projectile.h diff --git a/project/jni/application/gemrb/src/core/ProjectileMgr.cpp b/project/jni/application/gemrb/gemrb/core/ProjectileMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ProjectileMgr.cpp rename to project/jni/application/gemrb/gemrb/core/ProjectileMgr.cpp diff --git a/project/jni/application/gemrb/src/core/ProjectileMgr.h b/project/jni/application/gemrb/gemrb/core/ProjectileMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/ProjectileMgr.h rename to project/jni/application/gemrb/gemrb/core/ProjectileMgr.h diff --git a/project/jni/application/gemrb/src/core/ProjectileServer.cpp b/project/jni/application/gemrb/gemrb/core/ProjectileServer.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ProjectileServer.cpp rename to project/jni/application/gemrb/gemrb/core/ProjectileServer.cpp diff --git a/project/jni/application/gemrb/src/core/ProjectileServer.h b/project/jni/application/gemrb/gemrb/core/ProjectileServer.h similarity index 100% rename from project/jni/application/gemrb/src/core/ProjectileServer.h rename to project/jni/application/gemrb/gemrb/core/ProjectileServer.h diff --git a/project/jni/application/gemrb/src/core/Region.cpp b/project/jni/application/gemrb/gemrb/core/Region.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Region.cpp rename to project/jni/application/gemrb/gemrb/core/Region.cpp diff --git a/project/jni/application/gemrb/src/core/Region.h b/project/jni/application/gemrb/gemrb/core/Region.h similarity index 100% rename from project/jni/application/gemrb/src/core/Region.h rename to project/jni/application/gemrb/gemrb/core/Region.h diff --git a/project/jni/application/gemrb/src/core/Resource.cpp b/project/jni/application/gemrb/gemrb/core/Resource.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Resource.cpp rename to project/jni/application/gemrb/gemrb/core/Resource.cpp diff --git a/project/jni/application/gemrb/src/core/Resource.h b/project/jni/application/gemrb/gemrb/core/Resource.h similarity index 100% rename from project/jni/application/gemrb/src/core/Resource.h rename to project/jni/application/gemrb/gemrb/core/Resource.h diff --git a/project/jni/application/gemrb/src/core/ResourceDesc.cpp b/project/jni/application/gemrb/gemrb/core/ResourceDesc.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ResourceDesc.cpp rename to project/jni/application/gemrb/gemrb/core/ResourceDesc.cpp diff --git a/project/jni/application/gemrb/src/core/ResourceDesc.h b/project/jni/application/gemrb/gemrb/core/ResourceDesc.h similarity index 100% rename from project/jni/application/gemrb/src/core/ResourceDesc.h rename to project/jni/application/gemrb/gemrb/core/ResourceDesc.h diff --git a/project/jni/application/gemrb/src/core/ResourceManager.cpp b/project/jni/application/gemrb/gemrb/core/ResourceManager.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ResourceManager.cpp rename to project/jni/application/gemrb/gemrb/core/ResourceManager.cpp diff --git a/project/jni/application/gemrb/src/core/ResourceManager.h b/project/jni/application/gemrb/gemrb/core/ResourceManager.h similarity index 100% rename from project/jni/application/gemrb/src/core/ResourceManager.h rename to project/jni/application/gemrb/gemrb/core/ResourceManager.h diff --git a/project/jni/application/gemrb/src/core/ResourceSource.cpp b/project/jni/application/gemrb/gemrb/core/ResourceSource.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ResourceSource.cpp rename to project/jni/application/gemrb/gemrb/core/ResourceSource.cpp diff --git a/project/jni/application/gemrb/src/core/ResourceSource.h b/project/jni/application/gemrb/gemrb/core/ResourceSource.h similarity index 100% rename from project/jni/application/gemrb/src/core/ResourceSource.h rename to project/jni/application/gemrb/gemrb/core/ResourceSource.h diff --git a/project/jni/application/gemrb/src/core/SaveGame.h b/project/jni/application/gemrb/gemrb/core/SaveGame.h similarity index 100% rename from project/jni/application/gemrb/src/core/SaveGame.h rename to project/jni/application/gemrb/gemrb/core/SaveGame.h diff --git a/project/jni/application/gemrb/src/core/SaveGameIterator.cpp b/project/jni/application/gemrb/gemrb/core/SaveGameIterator.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/SaveGameIterator.cpp rename to project/jni/application/gemrb/gemrb/core/SaveGameIterator.cpp diff --git a/project/jni/application/gemrb/src/core/SaveGameIterator.h b/project/jni/application/gemrb/gemrb/core/SaveGameIterator.h similarity index 100% rename from project/jni/application/gemrb/src/core/SaveGameIterator.h rename to project/jni/application/gemrb/gemrb/core/SaveGameIterator.h diff --git a/project/jni/application/gemrb/src/core/SaveGameMgr.cpp b/project/jni/application/gemrb/gemrb/core/SaveGameMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/SaveGameMgr.cpp rename to project/jni/application/gemrb/gemrb/core/SaveGameMgr.cpp diff --git a/project/jni/application/gemrb/src/core/SaveGameMgr.h b/project/jni/application/gemrb/gemrb/core/SaveGameMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/SaveGameMgr.h rename to project/jni/application/gemrb/gemrb/core/SaveGameMgr.h diff --git a/project/jni/application/gemrb/src/core/ScriptEngine.cpp b/project/jni/application/gemrb/gemrb/core/ScriptEngine.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ScriptEngine.cpp rename to project/jni/application/gemrb/gemrb/core/ScriptEngine.cpp diff --git a/project/jni/application/gemrb/src/core/ScriptEngine.h b/project/jni/application/gemrb/gemrb/core/ScriptEngine.h similarity index 100% rename from project/jni/application/gemrb/src/core/ScriptEngine.h rename to project/jni/application/gemrb/gemrb/core/ScriptEngine.h diff --git a/project/jni/application/gemrb/src/core/Scriptable/Actor.cpp b/project/jni/application/gemrb/gemrb/core/Scriptable/Actor.cpp similarity index 96% rename from project/jni/application/gemrb/src/core/Scriptable/Actor.cpp rename to project/jni/application/gemrb/gemrb/core/Scriptable/Actor.cpp index f83a0ff2e..bf07faf3e 100644 --- a/project/jni/application/gemrb/src/core/Scriptable/Actor.cpp +++ b/project/jni/application/gemrb/gemrb/core/Scriptable/Actor.cpp @@ -88,10 +88,13 @@ static int xpbonuslevels = -1; static int **levelslots = NULL; static int *dualswap = NULL; static int *maxhpconbon = NULL; +static int *skillstats = NULL; +static int *skillabils = NULL; +static int skillcount = -1; static ieVariable CounterNames[4]={"GOOD","LAW","LADY","MURDER"}; static int FistRows = -1; -int *wmlevels[20]; +static int *wmlevels[20]; typedef ieResRef FistResType[MAX_LEVEL+1]; static FistResType *fistres = NULL; @@ -343,6 +346,7 @@ Actor::Actor() LastDamage = 0; LastDamageType = 0; LastTurner = 0; + LastExit = 0; HotKey = 0; attackcount = 0; secondround = 0; @@ -404,8 +408,10 @@ Actor::Actor() //this one is not saved GotLUFeedback = false; RollSaves(); + WMLevelMod = 0; polymorphCache = NULL; + memset(&wildSurgeMods, 0, sizeof(wildSurgeMods)); } Actor::~Actor(void) @@ -475,10 +481,12 @@ void Actor::SetName(int strref, unsigned char type) if (type!=2) { if (LongName) free(LongName); LongName = core->GetString( strref, IE_STR_REMOVE_NEWLINE ); + LongStrRef = strref; } if (type!=1) { if (ShortName) free(ShortName); ShortName = core->GetString( strref, IE_STR_REMOVE_NEWLINE ); + ShortStrRef = strref; } } @@ -549,7 +557,7 @@ void Actor::SetAnimationID(unsigned int AnimID) } -CharAnimations* Actor::GetAnims() +CharAnimations* Actor::GetAnims() const { return anims; } @@ -719,7 +727,7 @@ bool Actor::ApplyKit(bool remove) //multi class if (multiclass) { ieDword msk = 1; - for(unsigned int i=1;(i<32) && (msk<=multiclass);i++) { + for(unsigned int i=1;(i<(unsigned int) classcount) && (msk<=multiclass);i++) { if (multiclass & msk) { max = GetClassLevel(levelslotsbg[i]); // don't apply/remove the old kit clab if the kit is disabled @@ -735,11 +743,13 @@ bool Actor::ApplyKit(bool remove) } //single class ieDword cls = GetStat(IE_CLASS); + if (cls<(ieDword) classcount) { + return false; + } max = GetClassLevel(levelslotsbg[cls]); if (kitclass==cls) { ApplyClab(clab, max, remove); - } - else { + } else { ApplyClab(classabilities[cls], max, remove); } return true; @@ -1247,6 +1257,15 @@ void Actor::ReleaseMemory() free(maxhpconbon); maxhpconbon=NULL; } + if (skillstats) { + free(skillstats); + skillstats=NULL; + } + if (skillabils) { + free(skillabils); + skillabils=NULL; + } + if (wspecial) { for (i=0; i<=wspecial_max; i++) { if (wspecial[i]) { @@ -1899,6 +1918,21 @@ static void InitActorTables() VCMap[row]=value; } } + + //initializing the skill->stats conversion table (used in iwd2) + tm.load("skillsta"); + if (tm) { + int rowcount = tm->GetRowCount(); + skillcount = rowcount; + if (rowcount) { + skillstats = (int *) malloc(rowcount * sizeof(int) ); + skillabils = (int *) malloc(rowcount * sizeof(int) ); + while(rowcount--) { + skillstats[rowcount]=core->TranslateStat(tm->QueryField(rowcount,0)); + skillabils[rowcount]=core->TranslateStat(tm->QueryField(rowcount,1)); + } + } + } } void Actor::SetLockedPalette(const ieDword *gradients) @@ -2018,7 +2052,7 @@ int Actor::GetMod(unsigned int StatIndex) return (signed) Modified[StatIndex] - (signed) BaseStats[StatIndex]; } /** Returns a Stat Base Value */ -ieDword Actor::GetBase(unsigned int StatIndex) +ieDword Actor::GetBase(unsigned int StatIndex) const { if (StatIndex >= MAX_STATS) { return 0xffff; @@ -2092,7 +2126,7 @@ bool Actor::SetBaseBit(unsigned int StatIndex, ieDword Value, bool setreset) return true; } -const unsigned char *Actor::GetStateString() +const unsigned char *Actor::GetStateString() const { if (!PCStats) { return NULL; @@ -2151,12 +2185,16 @@ void Actor::RefreshEffects(EffectQueue *fx) //put all special cleanup calls here CharAnimations* anims = GetAnims(); if (anims) { - anims->GlobalColorMod.type = RGBModifier::NONE; - anims->GlobalColorMod.speed = 0; + if (!anims->GlobalColorMod.locked) { + anims->GlobalColorMod.type = RGBModifier::NONE; + anims->GlobalColorMod.speed = 0; + } unsigned int location; for (location = 0; location < 32; ++location) { - anims->ColorMods[location].type = RGBModifier::NONE; - anims->ColorMods[location].speed = 0; + if (!anims->ColorMods[location].phase) { + anims->ColorMods[location].type = RGBModifier::NONE; + anims->ColorMods[location].speed = 0; + } } } spellbook.ClearBonus(); @@ -2317,10 +2355,15 @@ void Actor::RefreshPCStats() { } else { //wspattack appears to only effect warriors int defaultattacks = 2 + 2*dualwielding; - if (tmplevel) { - SetBase(IE_NUMBEROFATTACKS, defaultattacks+wspattack[stars][tmplevel]); + if (stars) { + if (tmplevel) { + SetBase(IE_NUMBEROFATTACKS, defaultattacks+wspattack[stars][tmplevel]); + } else { + SetBase(IE_NUMBEROFATTACKS, defaultattacks); + } } else { - SetBase(IE_NUMBEROFATTACKS, defaultattacks); + // unproficient user - force defaultattacks + SetStat(IE_NUMBEROFATTACKS, defaultattacks, 0); } } } @@ -2681,9 +2724,6 @@ int Actor::Damage(int damage, int damagetype, Scriptable *hitter, int modtype) int resisted = 0; ModifyDamage (this, hitter, damage, resisted, damagetype, NULL, false); - if (damage) { - GetHit(); - } DisplayCombatFeedback(damage, resisted, damagetype, hitter); @@ -2691,14 +2731,26 @@ int Actor::Damage(int damage, int damagetype, Scriptable *hitter, int modtype) // common fists do normal damage, but cause sleeping for a round instead of death if ((damagetype & DAMAGE_STUNNING) && Modified[IE_MINHITPOINTS] <= 0) { NewBase(IE_HITPOINTS, 1, MOD_ABSOLUTE); - Effect *fx = EffectQueue::CreateEffect(fx_sleep_ref, 0, 0, FX_DURATION_INSTANT_LIMITED); - fx->Duration = core->Time.round_sec; // 1 round - core->ApplyEffect(fx, this, this); - delete fx; + // stack unconsciousness carefully to avoid replaying the stance changing + Effect *sleep = fxqueue.HasEffectWithParamPair(fx_sleep_ref, 0, 0); + if (sleep) { + sleep->Duration += core->Time.round_sec; + } else { + Effect *fx = EffectQueue::CreateEffect(fx_sleep_ref, 0, 0, FX_DURATION_INSTANT_LIMITED); + fx->Duration = core->Time.round_sec; // 1 round + core->ApplyEffect(fx, this, this); + delete fx; + } } else { + if (damage) { + GetHit(); + } NewBase(IE_HITPOINTS, (ieDword) -damage, MOD_ADDITIVE); } } else { + if (damage) { + GetHit(); + } NewBase(IE_HITPOINTS, (ieDword) -damage, MOD_ADDITIVE); // also apply reputation damage if we hurt (but not killed) an innocent @@ -3081,17 +3133,55 @@ ieDword Actor::GetXPLevel(int modified) const return ieDword(average); } -int Actor::GetWildMod(int level) const +// returns the guessed caster level by passed spell type +// FIXME: add iwd2 support (should be more precise, as there are more class types) +// FIXME: add more logic for cross-type kits (like avengers)? +ieDword Actor::GetBaseCasterLevel(int spelltype) const { - if(GetStat(IE_KIT)&0x8000) { - if (level>=MAX_LEVEL) level=MAX_LEVEL; - if(level<1) level=1; - return wmlevels[core->Roll(1,20,-1)][level-1]; + int level = 0; + + switch(spelltype) + { + case IE_SPL_PRIEST: + level = GetClericLevel(); + if (!level) level = GetDruidLevel(); + if (!level) level = GetPaladinLevel(); + if (!level) level = GetRangerLevel(); + break; + case IE_SPL_WIZARD: + level = GetMageLevel(); + if (!level) level = GetSorcererLevel(); + if (!level) level = GetBardLevel(); + break; + } + // if nothing was found, use the average level + if (!level) level = GetXPLevel(true); + + return level; +} + +int Actor::GetWildMod(int level) +{ + if(GetStat(IE_KIT)&0x1e) { + // avoid rerolling the mod, since we get called multiple times per each cast + if (!WMLevelMod) { + if (level>=MAX_LEVEL) level=MAX_LEVEL; + if(level<1) level=1; + WMLevelMod = wmlevels[core->Roll(1,20,-1)][level-1]; + + core->GetTokenDictionary()->SetAtCopy("LEVELDIF", abs(WMLevelMod)); + if (WMLevelMod > 0) { + displaymsg->DisplayConstantStringName(STR_CASTER_LVL_INC, 0xffffff, this); + } else if (WMLevelMod < 0) { + displaymsg->DisplayConstantStringName(STR_CASTER_LVL_DEC, 0xffffff, this); + } + } + return WMLevelMod; } return 0; } -int Actor::CastingLevelBonus(int level, int type) const +int Actor::CastingLevelBonus(int level, int type) { int bonus = 0; switch(type) @@ -3103,21 +3193,15 @@ int Actor::CastingLevelBonus(int level, int type) const bonus = GetWildMod(level) + GetStat(IE_CASTINGLEVELBONUSMAGE); } - if (!bonus) { - return 0; - } - - core->GetTokenDictionary()->SetAtCopy("LEVELDIF", bonus); - - if (bonus > 0) { - displaymsg->DisplayConstantStringName(STR_CASTER_LVL_INC, 0xffffff, this); - } else { - displaymsg->DisplayConstantStringName(STR_CASTER_LVL_DEC, 0xffffff, this); - } - return bonus; } +ieDword Actor::GetCasterLevel(int spelltype) +{ + int level = GetBaseCasterLevel(spelltype); + return level + CastingLevelBonus(level, spelltype); +} + /** maybe this would be more useful if we calculate with the strength too */ int Actor::GetEncumbrance() @@ -3864,7 +3948,7 @@ int Actor::IsDualWielding() const //returns weapon header currently used (bow in case of bow+arrow) //if range is nonzero, then the returned header is valid -ITMExtHeader *Actor::GetWeapon(WeaponInfo &wi, bool leftorright) +ITMExtHeader *Actor::GetWeapon(WeaponInfo &wi, bool leftorright) const { //only use the shield slot if we are dual wielding leftorright = leftorright && IsDualWielding(); @@ -3940,7 +4024,18 @@ int Actor::LearnSpell(const ieResRef spellname, ieDword flags) if (flags & LS_STATS) { // chance to learn roll - if (LuckyRoll(1,100,0) > core->GetIntelligenceBonus(0, GetStat(IE_INT))) { + int roll = LuckyRoll(1, 100, 0); + // adjust the roll for specialist mages + // doesn't work in bg1, since its spells don't have PrimaryType set + if (GetKitIndex(BaseStats[IE_KIT])) { + if ((signed)BaseStats[IE_KIT] == 1<<(spell->PrimaryType+5)) { // +5 since the kit values start at 0x40 + roll += 15; + } else { + roll -= 15; + } + } + + if (roll > core->GetIntelligenceBonus(0, GetStat(IE_INT))) { return LSR_FAILED; } } @@ -4069,7 +4164,7 @@ void Actor::SetModalSpell(ieDword state, const char *spell) //this is just a stub function for now, attackstyle could be melee/ranged //even spells got this attack style -int Actor::GetAttackStyle() +int Actor::GetAttackStyle() const { WeaponInfo wi; //Non NULL if the equipped slot is a projectile or a throwing weapon @@ -4202,7 +4297,7 @@ void Actor::InitRound(ieDword gameTime) } bool Actor::GetCombatDetails(int &tohit, bool leftorright, WeaponInfo& wi, ITMExtHeader *&header, ITMExtHeader *&hittingheader, \ - ieDword &Flags, int &DamageBonus, int &speed, int &CriticalBonus, int &style) + ieDword &Flags, int &DamageBonus, int &speed, int &CriticalBonus, int &style, Actor *target) const { tohit = GetStat(IE_TOHIT); speed = -GetStat(IE_PHYSICALSPEED); @@ -4229,7 +4324,7 @@ bool Actor::GetCombatDetails(int &tohit, bool leftorright, WeaponInfo& wi, ITMEx if (!rangedheader) { //display out of ammo verbal constant if there is any??? //DisplayStringCore(this, VB_OUTOFAMMO, DS_CONSOLE|DS_CONST ); - SetStance(IE_ANI_READY); + //SetStance(IE_ANI_READY); //set some trigger? return false; } @@ -4241,7 +4336,7 @@ bool Actor::GetCombatDetails(int &tohit, bool leftorright, WeaponInfo& wi, ITMEx break; default: //item is unsuitable for fight - SetStance(IE_ANI_READY); + //SetStance(IE_ANI_READY); return false; }//melee or ranged //this flag is set by the bow in case of projectile launcher. @@ -4315,7 +4410,7 @@ bool Actor::GetCombatDetails(int &tohit, bool leftorright, WeaponInfo& wi, ITMEx // TODO: Elves get a racial THAC0 bonus with all swords and bows in BG2 (but not daggers) //second parameter is left or right hand flag - tohit = GetToHit(THAC0Bonus, Flags); + tohit = GetToHit(THAC0Bonus, Flags, target); //pst increased critical hits if (pstflags && (Modified[IE_STATE_ID]&STATE_CRIT_ENH)) { @@ -4324,7 +4419,14 @@ bool Actor::GetCombatDetails(int &tohit, bool leftorright, WeaponInfo& wi, ITMEx return true; } -int Actor::GetToHit(int bonus, ieDword Flags) +int Actor::MeleePenalty() const +{ + if (GetMonkLevel()) return 0; + if (inventory.GetEquippedSlot()!=IW_NO_EQUIPPED) return 4; + return 0; +} + +int Actor::GetToHit(int bonus, ieDword Flags, Actor *target) const { int tohit = bonus; @@ -4357,19 +4459,22 @@ int Actor::GetToHit(int bonus, ieDword Flags) tohit += core->GetStrengthBonus(0,GetStat(IE_STR), GetStat(IE_STREXTRA) ); } - // if the target is using a ranged weapon while we're meleeing, we get a +4 bonus - if ((Flags&WEAPON_STYLEMASK) != WEAPON_RANGED) { - Actor *target = area->GetActorByGlobalID(LastTarget); - if (target && target->GetAttackStyle() == WEAPON_RANGED) { - tohit += 4; + if (target) { + // if the target is using a ranged weapon while we're meleeing, we get a +4 bonus + if ((Flags&WEAPON_STYLEMASK) != WEAPON_RANGED) { + if (target->GetAttackStyle() == WEAPON_RANGED) { + tohit += 4; + } } - } - // add +4 attack bonus vs racial enemies - if (GetRangerLevel()) { - Actor *target = area->GetActorByGlobalID(LastTarget); - if (target && IsRacialEnemy(target)) { - tohit += 4; + // melee vs. unarmed + tohit += target->MeleePenalty() - MeleePenalty(); + + // add +4 attack bonus vs racial enemies + if (GetRangerLevel()) { + if (IsRacialEnemy(target)) { + tohit += 4; + } } } @@ -4384,7 +4489,7 @@ int Actor::GetToHit(int bonus, ieDword Flags) static const int weapon_damagetype[] = {DAMAGE_CRUSHING, DAMAGE_PIERCING, DAMAGE_CRUSHING, DAMAGE_SLASHING, DAMAGE_MISSILE, DAMAGE_STUNNING}; -int Actor::GetDefense(int DamageType) +int Actor::GetDefense(int DamageType) const { //specific damage type bonus. int defense = 0; @@ -4507,7 +4612,7 @@ void Actor::PerformAttack(ieDword gameTime) int speed, style; //will return false on any errors (eg, unusable weapon) - if (!GetCombatDetails(tohit, leftorright, wi, header, hittingheader, Flags, DamageBonus, speed, CriticalBonus, style)) { + if (!GetCombatDetails(tohit, leftorright, wi, header, hittingheader, Flags, DamageBonus, speed, CriticalBonus, style, target)) { return; } @@ -4517,9 +4622,8 @@ void Actor::PerformAttack(ieDword gameTime) // speed contains the bonus from the physical speed stat and the proficiency level int spdfactor = hittingheader->Speed + speed; if (spdfactor<0) spdfactor = 0; - // FIXME: make LuckyRoll also be able to use luck as a malus // -3: k/2 in the original, hardcoded to 6; -1 for the difference in rolls - the original rolled 0-5 - spdfactor += core->Roll(1, 6, -Modified[IE_LUCK]) - 4; + spdfactor += LuckyRoll(1, 6, -4, LR_NEGATIVE); if (spdfactor<0) spdfactor = 0; if (spdfactor>10) spdfactor = 10; @@ -4585,7 +4689,7 @@ void Actor::PerformAttack(ieDword gameTime) int resisted = 0; if (hittingheader->DiceThrown<256) { - damage += LuckyRoll(hittingheader->DiceThrown, hittingheader->DiceSides, 0, 1, 0); + damage += LuckyRoll(hittingheader->DiceThrown, hittingheader->DiceSides, 0, LR_CRITICAL); damage += DamageBonus; printf("| Damage %dd%d%+d = %d ",hittingheader->DiceThrown, hittingheader->DiceSides, DamageBonus, damage); } else { @@ -4720,7 +4824,7 @@ void Actor::ModifyDamage(Actor *target, Scriptable *hitter, int &damage, int &re // damage type without a resistance stat } else { damage += (signed)target->GetStat(IE_DAMAGEBONUS); - resisted = (int) (damage * (signed)target->GetStat(it->second.resist_stat)/100.0); + resisted = (int) (damage * (signed)target->GetSafeStat(it->second.resist_stat)/100.0); // check for bonuses for specific damage types if (core->HasFeature(GF_SPECIFIC_DMG_BONUS) && hitter && hitter->Type == ST_ACTOR) { int bonus = ((Actor *)hitter)->fxqueue.SpecificDamageBonus(it->second.iwd_mod_type); @@ -4730,7 +4834,7 @@ void Actor::ModifyDamage(Actor *target, Scriptable *hitter, int &damage, int &re } } damage -= resisted; - printf("Resisted %d of %d at %d%% resistance to %d\n", resisted, damage+resisted, target->GetStat(it->second.resist_stat), damagetype); + printf("Resisted %d of %d at %d%% resistance to %d\n", resisted, damage+resisted, target->GetSafeStat(it->second.resist_stat), damagetype); if (damage <= 0) resisted = DR_IMMUNE; } } @@ -4878,6 +4982,8 @@ void Actor::SetColorMod( ieDword location, RGBModifier::Type type, int speed, if (!ca) return; if (location == 0xff) { + if (phase && ca->GlobalColorMod.locked) return; + ca->GlobalColorMod.locked = !phase; ca->GlobalColorMod.type = type; ca->GlobalColorMod.speed = speed; ca->GlobalColorMod.rgb.r = r; @@ -4894,6 +5000,7 @@ void Actor::SetColorMod( ieDword location, RGBModifier::Type type, int speed, } //00xx0yyy-->000xxyyy if (location&0xffffffc8) return; //invalid location + if (phase && ca->ColorMods[location].locked) return; location = (location &7) | ((location>>1)&0x18); ca->ColorMods[location].type = type; ca->ColorMods[location].speed = speed; @@ -5517,7 +5624,7 @@ bool Actor::HandleActorStance() return false; } -void Actor::GetSoundFrom2DA(ieResRef Sound, unsigned int index) +void Actor::GetSoundFrom2DA(ieResRef Sound, unsigned int index) const { if (!anims) return; @@ -5552,7 +5659,7 @@ void Actor::GetSoundFrom2DA(ieResRef Sound, unsigned int index) strnlwrcpy(Sound, tab->QueryField (index, col), 8); } -void Actor::GetSoundFromINI(ieResRef Sound, unsigned int index) +void Actor::GetSoundFromINI(ieResRef Sound, unsigned int index) const { const char *resource = ""; char section[12]; @@ -5587,7 +5694,7 @@ void Actor::GetSoundFromINI(ieResRef Sound, unsigned int index) Sound[count]=0; } -void Actor::ResolveStringConstant(ieResRef Sound, unsigned int index) +void Actor::ResolveStringConstant(ieResRef Sound, unsigned int index) const { if (PCStats && PCStats->SoundSet[0]) { //resolving soundset (bg1/bg2 style) @@ -5709,15 +5816,15 @@ void Actor::GetSoundFolder(char *soundset, int full) const } } -bool Actor::HasVVCCell(const ieResRef resource) +bool Actor::HasVVCCell(const ieResRef resource) const { return GetVVCCell(resource) != NULL; } -ScriptedAnimation *Actor::GetVVCCell(const ieResRef resource) +ScriptedAnimation *Actor::GetVVCCell(const ieResRef resource) const { int j = true; - vvcVector *vvcCells=&vvcShields; + const vvcVector *vvcCells=&vvcShields; retry: size_t i=vvcCells->size(); while (i--) { @@ -5761,9 +5868,9 @@ retry: //this is a faster version of hasvvccell, because it knows where to look //for the overlay, it also returns the vvc for further manipulation //use this for the seven eyes overlay -ScriptedAnimation *Actor::FindOverlay(int index) +ScriptedAnimation *Actor::FindOverlay(int index) const { - vvcVector *vvcCells; + const vvcVector *vvcCells; if (index>31) return NULL; @@ -5863,7 +5970,7 @@ void Actor::Rest(int hours) } //returns the actual slot from the quickslot -int Actor::GetQuickSlot(int slot) +int Actor::GetQuickSlot(int slot) const { assert(slot<8); if (inventory.HasItemInSlot("",inventory.GetMagicSlot())) { @@ -6348,7 +6455,7 @@ bool Actor::SetSpellState(unsigned int spellstate) } //returns true if spell state is already set -bool Actor::HasSpellState(unsigned int spellstate) +bool Actor::HasSpellState(unsigned int spellstate) const { if (spellstate>=192) return false; unsigned int pos = IE_SPLSTATE_ID1+(spellstate>>5); @@ -6357,6 +6464,20 @@ bool Actor::HasSpellState(unsigned int spellstate) return false; } +//this is a very specific rule that might need an external table later +int Actor::GetAbilityBonus(unsigned int ability) const +{ + return GetStat(ability)/2-5; +} + +int Actor::GetSkill(unsigned int skill) const +{ + if (skill>=(unsigned int) skillcount) return -1; + int ret = GetStat(skillstats[skill])+GetAbilityBonus(skillabils[skill]); + if (ret<0) ret = 0; + return ret; +} + //returns the numeric value of a feat, different from HasFeat //for multiple feats int Actor::GetFeat(unsigned int feat) const @@ -6683,43 +6804,54 @@ bool Actor::BlocksSearchMap() const } //return true if the actor doesn't want to use an entrance -bool Actor::CannotPassEntrance() const +bool Actor::CannotPassEntrance(ieDword exitID) const { + if (LastExit!=exitID) { + return true; + } + if (InternalFlags&IF_USEEXIT) { return false; } + return true; } -void Actor::UseExit(int flag) { - if (flag) { +void Actor::UseExit(ieDword exitID) { + if (exitID) { InternalFlags|=IF_USEEXIT; } else { InternalFlags&=~IF_USEEXIT; } + LastExit = exitID; } // luck increases the minimum roll per dice, but only up to the number of dice sides; // luck does not affect critical hit chances: // if critical is set, it will return 1/sides on a critical, otherwise it can never // return a critical miss when luck is positive and can return a false critical hit -int Actor::LuckyRoll(int dice, int size, int add, bool critical, bool only_damage, Actor* opponent) const +int Actor::LuckyRoll(int dice, int size, int add, ieDword flags, Actor* opponent) const { assert(this != opponent); ieDword stat; - if (only_damage) { + if (flags&LR_DAMAGELUCK) { stat = IE_DAMAGELUCK; } else { stat = IE_LUCK; } - int luck = (signed) GetStat(stat); + int luck = (signed) GetSafeStat(stat); + if (flags&LR_NEGATIVE) { + luck = -luck; + } if (opponent) luck -= (signed) opponent->GetStat(stat); if (dice < 1 || size < 1) { return add + luck; } + ieDword critical = flags&LR_CRITICAL; + if (dice > 100) { int bonus; if (abs(luck) > size) { @@ -6801,7 +6933,7 @@ void Actor::ResetState() // doesn't check the range, but only that the azimuth and the target // orientation match with a +/-2 allowed difference -bool Actor::IsBehind(Actor* target) +bool Actor::IsBehind(Actor* target) const { unsigned char tar_orient = target->GetOrientation(); // computed, since we don't care where we face @@ -6818,7 +6950,7 @@ bool Actor::IsBehind(Actor* target) } // checks all the actor's stats to see if the target is her racial enemy -bool Actor::IsRacialEnemy(Actor* target) +bool Actor::IsRacialEnemy(Actor* target) const { if (Modified[IE_HATEDRACE] == target->Modified[IE_RACE]) { return true; @@ -6900,14 +7032,14 @@ bool Actor::TryToHide() { return true; } -bool Actor::InvalidSpellTarget() +bool Actor::InvalidSpellTarget() const { if (GetStat(IE_STATE_ID) & (STATE_DEAD)) return true; if (HasSpellState(SS_SANCTUARY)) return true; return false; } -bool Actor::InvalidSpellTarget(int spellnum, Actor *caster, int range) +bool Actor::InvalidSpellTarget(int spellnum, Actor *caster, int range) const { ieResRef spellres; @@ -6931,7 +7063,7 @@ bool Actor::PCInDark() const return false; } -int Actor::GetClassMask() +int Actor::GetClassMask() const { int classmask = 0; for (int i=0; i < ISCLASSES; i++) { diff --git a/project/jni/application/gemrb/src/core/Scriptable/Actor.h b/project/jni/application/gemrb/gemrb/core/Scriptable/Actor.h similarity index 91% rename from project/jni/application/gemrb/src/core/Scriptable/Actor.h rename to project/jni/application/gemrb/gemrb/core/Scriptable/Actor.h index cc847308f..358fdd357 100644 --- a/project/jni/application/gemrb/src/core/Scriptable/Actor.h +++ b/project/jni/application/gemrb/gemrb/core/Scriptable/Actor.h @@ -49,7 +49,12 @@ struct PolymorphCache; #define MAX_STATS 256 #define MAX_LEVEL 128 -#define MAX_FEATS 96 //3*sizeof(ieDword) +#define MAX_FEATS 96 //3*sizeof(ieDword) + +//lucky roll +#define LR_CRITICAL 1 +#define LR_DAMAGELUCK 2 +#define LR_NEGATIVE 4 //modal states #define MS_NONE 0 @@ -179,6 +184,20 @@ struct PolymorphCache; // used for distinguishing damage immunity from high damage resistance #define DR_IMMUNE 999999 +// wild surge target change type +#define WSTC_SETTYPE 1 // change to this target type +#define WSTC_ADDTYPE 2 // affect also this target type +#define WSTC_RANDOMIZE 3 // choose a random target +struct WildSurgeSpellMods { + unsigned int num_castings; // number of times to cast + unsigned int num_wildrolls; // number of times to roll + unsigned int projectile_id; // new projectile id + unsigned int target_change_type; // settype, addtype, randomize + unsigned int target_type; // type to use when target_change_type is not WSTC_RANDOMIZE + unsigned int projectile_speed_mod; // factor in percents + int saving_throw_mod; +}; + typedef ieByte ActionButtonRow[GUIBT_COUNT]; struct ActionButtonRow2 { ActionButtonRow buttons; @@ -268,16 +287,18 @@ public: ieDword LastCommander; ieDword LastHelp; ieDword LastSeen; - ieDword LastMarked; // no idea if non-actors could mark objects + ieDword LastMarked; //no idea if non-actors could mark objects int LastMarkedSpell; //a spell number to cast ieDword LastHeard; ieDword HotKey; + ieDword LastExit; //the global ID of the exit to be used char ShieldRef[2]; char HelmetRef[2]; char WeaponRef[2]; int WeaponType; ieDword multiclass; bool GotLUFeedback; + int WMLevelMod; int LastCommand; //lastcommander int LastShout; //lastheard @@ -303,6 +324,7 @@ public: int speed; PolymorphCache *polymorphCache; // fx_polymorph etc + WildSurgeSpellMods wildSurgeMods; private: //this stuff doesn't get saved CharAnimations* anims; @@ -371,7 +393,7 @@ public: /** you better use SetStat, this stuff is only for special cases*/ void SetAnimationID(unsigned int AnimID); /** returns the animations */ - CharAnimations* GetAnims(); + CharAnimations* GetAnims() const; /** Re/Inits the Modified vector */ void RefreshEffects(EffectQueue *eqfx); /** gets saving throws */ @@ -389,7 +411,7 @@ public: /** Returns the difference */ int GetMod(unsigned int StatIndex); /** Returns a Stat Base Value */ - ieDword GetBase(unsigned int StatIndex); + ieDword GetBase(unsigned int StatIndex) const; /** Sets a Base Stat Value */ bool SetBase(unsigned int StatIndex, ieDword Value); bool SetBaseNoPCF(unsigned int StatIndex, ieDword Value); @@ -423,10 +445,13 @@ public: const char* GetScript(int ScriptIndex) const; /** Gets the Character's level for XP calculations */ ieDword GetXPLevel(int modified) const; + /** Guesses the (base) casting level */ + ieDword GetCasterLevel(int spelltype); + ieDword GetBaseCasterLevel(int spelltype) const; /** Returns the wild mage casting level modifier */ - int GetWildMod(int level) const; + int GetWildMod(int level); /** Returns any casting level modifier */ - int CastingLevelBonus(int level, int type) const; + int CastingLevelBonus(int level, int type); /** Gets the Dialog ResRef */ const char* GetDialog(int flags=GD_NORMAL) const; @@ -520,7 +545,7 @@ public: ITMExtHeader *GetRangedWeapon(WeaponInfo &wi) const; /* Returns current weapon range and extended header if range is nonzero, then which is valid */ - ITMExtHeader* GetWeapon(WeaponInfo &wi, bool leftorright=false); + ITMExtHeader* GetWeapon(WeaponInfo &wi, bool leftorright=false) const; /* Creates player statistics */ void CreateStats(); /* Heals actor by days */ @@ -534,20 +559,22 @@ public: /* Sets the modal spell after checks */ void SetModalSpell(ieDword state, const char *spell); /* returns current attack style */ - int GetAttackStyle(); + int GetAttackStyle() const; /* adds the combatants to the attackers list */ void AttackedBy(Actor *actor); /* sets target for immediate attack */ void SetTarget( Scriptable *actor); /* starts combat round*/ void InitRound(ieDword gameTime); + /* returns melee penalty */ + int MeleePenalty() const; /* gets the to hit value */ - int GetToHit(int bonus, ieDword Flags); + int GetToHit(int bonus, ieDword Flags, Actor *target) const; /* gets the defense against an attack */ - int GetDefense(int DamageType) ; + int GetDefense(int DamageType) const; /* get the current hit bonus */ bool GetCombatDetails(int &tohit, bool leftorright, WeaponInfo &wi, ITMExtHeader *&header, ITMExtHeader *&hittingheader,\ - ieDword &Flags, int &DamageBonus, int &speed, int &CriticalBonus, int &style); + ieDword &Flags, int &DamageBonus, int &speed, int &CriticalBonus, int &style, Actor *target) const; /* performs attack against target */ void PerformAttack(ieDword gameTime); /* ensures we can deal damage to a target */ @@ -570,9 +597,9 @@ public: /* overridden method, won't walk if dead */ void WalkTo(const Point &Des, ieDword flags, int MinDistance = 0); /* resolve string constant (sound will be altered) */ - void ResolveStringConstant(ieResRef sound, unsigned int index); - void GetSoundFromINI(ieResRef Sound, unsigned int index); - void GetSoundFrom2DA(ieResRef Sound, unsigned int index); + void ResolveStringConstant(ieResRef sound, unsigned int index) const; + void GetSoundFromINI(ieResRef Sound, unsigned int index) const; + void GetSoundFrom2DA(ieResRef Sound, unsigned int index) const; /* sets the quick slots */ void SetActionButtonRow(ActionButtonRow &ar); /* updates the quick slots */ @@ -591,12 +618,12 @@ public: /* remove a vvc from the list, graceful means animated removal */ void RemoveVVCell(const ieResRef vvcname, bool graceful); /* returns true if actor already has the overlay (slow) */ - bool HasVVCCell(const ieResRef resource); + bool HasVVCCell(const ieResRef resource) const; /* returns overlay if actor already has it (slow) */ - ScriptedAnimation *GetVVCCell(const ieResRef resource); + ScriptedAnimation *GetVVCCell(const ieResRef resource) const; /* returns the vvc pointer to a hardcoded overlay */ /* if it exists (faster than hasvvccell) */ - ScriptedAnimation *FindOverlay(int index); + ScriptedAnimation *FindOverlay(int index) const; /* draw videocells */ void DrawVideocells(const Region &screen, vvcVector &vvcCells, const Color &tint); @@ -610,13 +637,13 @@ public: /* rememorizes spells, cures fatigue, etc */ void Rest(int hours); /* returns the portrait icons list */ - const unsigned char *GetStateString(); + const unsigned char *GetStateString() const; /* adds a state icon to the list */ void AddPortraitIcon(ieByte icon); /* disables a state icon in the list, doesn't remove it! */ void DisablePortraitIcon(ieByte icon); /* returns which slot belongs to the quickweapon slot */ - int GetQuickSlot(int slot); + int GetQuickSlot(int slot) const; /* Sets equipped Quick slot, if header is -1, then use the current one */ int SetEquippedQuickSlot(int slot, int header); /* Uses an item on the target or point */ @@ -625,12 +652,14 @@ public: /* Deducts a charge from an item */ void ChargeItem(ieDword slot, ieDword header, CREItem *item, Item *itm, bool silent); /* If it returns true, then default AC=10 and the lesser the better */ - int IsReverseToHit(); + static int IsReverseToHit(); /* initialize the action buttons based on class. If forced, it will override previously customized or set buttons. */ void InitButtons(ieDword cls, bool forced); - void SetFeat(unsigned int feat, int mode); + int GetAbilityBonus(unsigned int ability) const; + int GetSkill(unsigned int skill) const; int GetFeat(unsigned int feat) const; + void SetFeat(unsigned int feat, int mode); void SetUsedWeapon(const char *AnimationType, ieWord *MeleeAnimation, int WeaponType=-1); void SetUsedShield(const char *AnimationType, int WeaponType=-1); @@ -649,7 +678,7 @@ public: /* Checks and sets a spellstate if it wasn't set yet */ bool SetSpellState(unsigned int spellstate); /* Checks a spellstate */ - bool HasSpellState(unsigned int spellstate); + bool HasSpellState(unsigned int spellstate) const; /* Checks a feat */ bool HasFeat(unsigned int featindex) const; /* Reports projectile immunity, nonzero if immune */ @@ -684,11 +713,11 @@ public: /* true if we are dual-wielding */ int IsDualWielding() const; bool BlocksSearchMap() const; - bool CannotPassEntrance() const; - void UseExit(int flag); - int GetReaction(); + bool CannotPassEntrance(ieDword exitID) const; + void UseExit(ieDword exitID); + //int GetReaction() const; /* Similar to Roll, but takes luck into account */ - int LuckyRoll(int dice, int size, int add, bool critical=1, bool only_damage=0, Actor* opponent=NULL) const; + int LuckyRoll(int dice, int size, int add, ieDword flags=1, Actor* opponent=NULL) const; /* removes normal invisibility (type 0) */ void CureInvisibility(); /* removes sanctuary */ @@ -696,23 +725,23 @@ public: /* resets the invisibility, sanctuary and modal states */ void ResetState(); /* checks whether the actor is behind the target */ - bool IsBehind(Actor* target); + bool IsBehind(Actor* target) const; /* checks whether the target is the actor's racial enemy */ - bool IsRacialEnemy(Actor* target); + bool IsRacialEnemy(Actor* target) const; /* checks whether the actor can stay in the current modal state */ bool ModalSpellSkillCheck(); /* does all the game logic checks to see if the actor can hide */ bool TryToHide(); /* checks if the alignment matches one of the masking constants */ - bool MatchesAlignmentMask(ieDword mask); + //bool MatchesAlignmentMask(ieDword mask); /* returns true if this actor is untargetable */ - bool InvalidSpellTarget(); + bool InvalidSpellTarget() const; /* returns true if the spell is useless to cast on target or the spell's range is smaller than range */ - bool InvalidSpellTarget(int spellnum, Actor *caster, int range); + bool InvalidSpellTarget(int spellnum, Actor *caster, int range) const; /* returns true if the lightmap under the actor is dark */ bool PCInDark() const; /* computes the actor's classmask (iwd2) */ - int GetClassMask(); + int GetClassMask() const; }; #endif diff --git a/project/jni/application/gemrb/src/core/Scriptable/ActorBlock.cpp b/project/jni/application/gemrb/gemrb/core/Scriptable/ActorBlock.cpp similarity index 78% rename from project/jni/application/gemrb/src/core/Scriptable/ActorBlock.cpp rename to project/jni/application/gemrb/gemrb/core/Scriptable/ActorBlock.cpp index ff1b5da3e..f16688788 100644 --- a/project/jni/application/gemrb/src/core/Scriptable/ActorBlock.cpp +++ b/project/jni/application/gemrb/gemrb/core/Scriptable/ActorBlock.cpp @@ -96,6 +96,7 @@ Scriptable::Scriptable(ScriptableType type) LastCasterSeen = 0; LastSpellSeen = 0xffffffff; SpellHeader = -1; + SpellResRef[0] = 0; LastTargetPos.empty(); locals = new Variables(); locals->SetType( GEM_VARIABLES_INT ); @@ -188,6 +189,10 @@ void Scriptable::SetScript(int index, GameScript* script) Scripts[index] = script; } +void Scriptable::SetSpellResRef(ieResRef resref) { + strnuprcpy(SpellResRef, resref, 8); +} + void Scriptable::DisplayHeadText(const char* text) { if (overHeadText) { @@ -593,22 +598,40 @@ static EffectRef fx_set_invisible_state_ref={"State:Invisible",NULL,-1}; void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool fake) { Spell* spl = gamedata->GetSpell( SpellResRef ); + Actor *caster = NULL; //PST has a weird effect, called Enoll Eva's duplication //it creates every projectile of the affected actor twice int duplicate = 1; + if (Type == ST_ACTOR) { + caster = (Actor *) this; + duplicate = caster->wildSurgeMods.num_castings; + if (!duplicate) { + duplicate = 1; + } + } if (core->HasFeature(GF_PST_STATE_FLAGS) && (Type == ST_ACTOR)) { - if ( ((Actor *)this)->GetStat(IE_STATE_ID)&STATE_EE_DUPL) { - duplicate = 2; + if (caster->GetStat(IE_STATE_ID)&STATE_EE_DUPL) { + duplicate *= 2; } } while(duplicate --) { - Projectile *pro = spl->GetProjectile(this, SpellHeader, LastTargetPos); - if (!pro) { - return; + Projectile *pro = NULL; + // jump through hoops to skip applying selftargetting spells to the caster + // if we'll be changing the target + int tct = 0; + if (caster) { + tct = caster->wildSurgeMods.target_change_type; } - pro->SetCaster(GetGlobalID()); + if (!caster || !tct || tct == WSTC_ADDTYPE || !caster->wildSurgeMods.projectile_id) { + pro = spl->GetProjectile(this, SpellHeader, LastTargetPos); + if (!pro) { + return; + } + pro->SetCaster(GetGlobalID()); + } + Point origin = Pos; if (Type == ST_TRIGGER || Type == ST_PROXIMITY) { // try and make projectiles start from the right trap position @@ -617,6 +640,106 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool origin = ((InfoPoint *)this)->TrapLaunch; } + if (caster) { + // check for the speed mod + if (caster->wildSurgeMods.projectile_speed_mod) { + pro->Speed = (pro->Speed * caster->wildSurgeMods.projectile_speed_mod) / 100; + if (!pro->Speed) { + pro->Speed = 1; + } + } + + // check for target (type) change + int count, i; + Actor *newact = NULL; + SPLExtHeader *seh = NULL; + Effect *fx = NULL; + switch (caster->wildSurgeMods.target_change_type) { + case WSTC_SETTYPE: + seh = &spl->ext_headers[SpellHeader]; + for (i=0; i < seh->FeatureCount; i++) { + seh->features[i].Target = caster->wildSurgeMods.target_type; + } + // we need to fetch the projectile, so the effect queue is created + // (skipped above) + pro = spl->GetProjectile(this, SpellHeader, LastTargetPos); + pro->SetCaster(GetGlobalID()); + break; + case WSTC_ADDTYPE: + // TODO: unhardcode to allow for mixing all the target types + // caster gets selftargetting fx when the projectile is fetched above + seh = &spl->ext_headers[SpellHeader]; + for (i=0; i < seh->FeatureCount; i++) { + if (seh->features[i].Target == FX_TARGET_SELF) { + seh->features[i].Target = caster->wildSurgeMods.target_type; + } else { + // also apply to the caster + fx = seh->features+i; + core->ApplyEffect(fx, caster, caster); + } + } + // we need to refetch the projectile, so the effect queue is created + pro = spl->GetProjectile(this, SpellHeader, LastTargetPos); + pro->SetCaster(GetGlobalID()); + break; + case WSTC_RANDOMIZE: + count = area->GetActorCount(false); + newact = area->GetActor(core->Roll(1,count,-1), false); + if (count > 1 && newact == caster) { + while (newact == caster) { + newact = area->GetActor(core->Roll(1,count,-1), false); + } + } + if (tgt) { + LastTarget = newact->GetGlobalID(); + LastTargetPos = newact->Pos; + } else { + // no better idea; I wonder if the original randomized point targets at all + LastTargetPos = newact->Pos; + } + + // make it also work for self-targetting spells: + // change the payload or this was all in vain + seh = &spl->ext_headers[SpellHeader]; + for (i=0; i < seh->FeatureCount; i++) { + if (seh->features[i].Target == FX_TARGET_SELF) { + seh->features[i].Target = FX_TARGET_PRESET; + } + } + // we need to fetch the projectile, so the effect queue is created + // (skipped above) + pro = spl->GetProjectile(this, SpellHeader, LastTargetPos); + pro->SetCaster(GetGlobalID()); + break; + default: //0 - do nothing + break; + } + + // apply the saving throw mod + if (caster->wildSurgeMods.saving_throw_mod) { + seh = &spl->ext_headers[SpellHeader]; + for (i=0; i < seh->FeatureCount; i++) { + seh->features[i].SavingThrowBonus += caster->wildSurgeMods.saving_throw_mod; + } + } + + // change the projectile + if (caster->wildSurgeMods.projectile_id) { + spl->ext_headers[SpellHeader].ProjectileAnimation = caster->wildSurgeMods.projectile_id; + // make it also work for self-targetting spells: + // change the payload or this was all in vain + seh = &spl->ext_headers[SpellHeader]; + for (i=0; i < seh->FeatureCount; i++) { + if (seh->features[i].Target == FX_TARGET_SELF) { + seh->features[i].Target = FX_TARGET_PRESET; + } + } + // we need to refetch the projectile, so the new one is used + pro = spl->GetProjectile(this, SpellHeader, LastTargetPos); + pro->SetCaster(GetGlobalID()); + } + } + if (tgt) { area->AddProjectile(pro, origin, LastTarget, fake); } else { @@ -651,9 +774,8 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool if(LastTarget) { if (target && (Type==ST_ACTOR) ) { - Actor *me = (Actor *) this; target->LastSpellOnMe = spellnum; - target->LastCasterOnMe = me->GetGlobalID(); + target->LastCasterOnMe = caster->GetGlobalID(); // don't cure invisibility if this is a self targetting invisibility spell // like shadow door //can't check GetEffectBlock, since it doesn't construct the queue for selftargetting spells @@ -668,11 +790,11 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool if (invis && spl->GetExtHeader(SpellHeader)->Target == TARGET_SELF) { //pass } else { - me->CureInvisibility(); + caster->CureInvisibility(); } // sanctuary ends with all hostile actions or when the caster targets someone else if (target != this || spl->Flags & SF_HOSTILE) { - me->CureSanctuary(); + caster->CureSanctuary(); } } } @@ -684,10 +806,12 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool } -void Scriptable::CastSpellPointEnd( const ieResRef SpellResRef ) +void Scriptable::CastSpellPointEnd() { + Actor *caster = NULL; if (Type == ST_ACTOR) { - ((Actor *) this)->SetStance(IE_ANI_CONJURE); + caster = ((Actor *) this); + caster->SetStance(IE_ANI_CONJURE); } if (SpellHeader == -1) { @@ -700,17 +824,27 @@ void Scriptable::CastSpellPointEnd( const ieResRef SpellResRef ) return; } + if (!SpellResRef) { + return; + } + CreateProjectile(SpellResRef, 0, false); SpellHeader = -1; + SpellResRef[0] = 0; LastTarget = 0; LastTargetPos.empty(); + if (caster) { + memset(&(caster->wildSurgeMods), 0, sizeof(caster->wildSurgeMods)); + } } -void Scriptable::CastSpellEnd( const ieResRef SpellResRef ) +void Scriptable::CastSpellEnd() { + Actor *caster = NULL; if (Type == ST_ACTOR) { - ((Actor *) this)->SetStance(IE_ANI_CONJURE); + caster = ((Actor *) this); + caster->SetStance(IE_ANI_CONJURE); } if (SpellHeader == -1) { @@ -721,68 +855,181 @@ void Scriptable::CastSpellEnd( const ieResRef SpellResRef ) SpellHeader = -1; return; } + if (!SpellResRef) { + return; + } + //if the projectile doesn't need to follow the target, then use the target position CreateProjectile(SpellResRef, LastTarget, GetSpellDistance(SpellResRef, this)==0xffffffff); SpellHeader = -1; + SpellResRef[0] = 0; LastTarget = 0; LastTargetPos.empty(); + if (caster) { + memset(&(caster->wildSurgeMods), 0, sizeof(caster->wildSurgeMods)); + } +} + +// check for input sanity and good casting conditions +int Scriptable::CanCast(const ieResRef SpellResRef) { + Spell* spl = gamedata->GetSpell(SpellResRef); + if (!spl) { + SpellHeader = -1; + printMessage("Scriptable", "Spell not found, aborting cast!\n", LIGHT_RED); + return 0; + } + + // check for area dead magic + // tob AR3004 is a dead magic area, but using a script with personal dead magic + if (area->GetInternalFlag()&AF_DEADMAGIC) { + // TODO: display fizzling animation + displaymsg->DisplayConstantStringName(STR_DEADMAGIC_FAIL, 0xffffff, this); + return 0; + } + + // various individual checks + if (Type == ST_ACTOR) { + Actor *actor = (Actor *) this; + + // check for silence + // only a handful of spells don't have a verbal component - + // the original hardcoded vocalize and a few more + // we (also) ignore nonmagic spells + if (actor->Modified[IE_STATE_ID] & STATE_SILENCED) { + if (!(core->GetSpecialSpell(spl->Name)&SP_SILENCE) && !(spl->Flags&SF_HLA)) { + printMessage("Scriptable", "Tried to cast while silenced!\n", YELLOW); + return 0; + } + } + + // check for personal dead magic + if (actor->Modified[IE_DEADMAGIC]) { + // TODO: display fizzling animation + displaymsg->DisplayConstantStringName(STR_DEADMAGIC_FAIL, 0xffffff, this); + return 0; + } + + // check for miscast magic and similar + ieDword roll = actor->LuckyRoll(1, 100, 0, 0); + bool failed = false; + switch(spl->SpellType) + { + case IE_SPL_PRIEST: + if (actor->Modified[IE_SPELLFAILUREPRIEST] >= roll) { + failed = true; + } + break; + case IE_SPL_WIZARD: + if (actor->Modified[IE_SPELLFAILUREMAGE] >= roll) { + failed = true; + } + break; + case IE_SPL_INNATE: + if (actor->Modified[IE_SPELLFAILUREINNATE] >= roll) { + failed = true; + } + break; + } + if (failed) { + // TODO: display fizzling animation + displaymsg->DisplayConstantStringName(STR_MISCASTMAGIC, 0xffffff, this); + return 0; + } + } + + return 1; } //set target as point //if spell needs to be depleted, do it //if spell is illegal stop casting -int Scriptable::CastSpellPoint( const ieResRef SpellResRef, const Point &target, bool deplete, bool instant ) +int Scriptable::CastSpellPoint( ieResRef &SpellRef, const Point &target, bool deplete, bool instant ) { LastTarget = 0; LastTargetPos.empty(); if (Type == ST_ACTOR) { Actor *actor = (Actor *) this; - if (actor->HandleCastingStance(SpellResRef,deplete) ) { + if (actor->HandleCastingStance(SpellRef,deplete) ) { + printMessage("Scriptable", "Spell not known or memorized, aborting cast!\n", LIGHT_RED); return -1; } } + if(!CanCast(SpellRef)) { + SpellResRef[0] = 0; + if (Type == ST_ACTOR) { + Actor *actor = (Actor *) this; + actor->SetStance(IE_ANI_READY); + } + return -1; + } + + if (!SpellResRef[0]) { + SetSpellResRef(SpellRef); + } + LastTargetPos = target; - return SpellCast(SpellResRef, instant); + + if(!CheckWildSurge()) { + return -1; + } + return SpellCast(instant); } //set target as actor (if target isn't actor, use its position) //if spell needs to be depleted, do it //if spell is illegal stop casting -int Scriptable::CastSpell( const ieResRef SpellResRef, Scriptable* target, bool deplete, bool instant ) +int Scriptable::CastSpell( ieResRef &SpellRef, Scriptable* target, bool deplete, bool instant ) { LastTarget = 0; LastTargetPos.empty(); if (Type == ST_ACTOR) { Actor *actor = (Actor *) this; - if (actor->HandleCastingStance(SpellResRef,deplete) ) { + if (actor->HandleCastingStance(SpellRef,deplete) ) { + printMessage("Scriptable", "Spell not known or memorized, aborting cast!\n", LIGHT_RED); return -1; } } + // FIXME: fishy if (!target) target = this; + if(!CanCast(SpellRef)) { + SpellResRef[0] = 0; + if (Type == ST_ACTOR) { + Actor *actor = (Actor *) this; + actor->SetStance(IE_ANI_READY); + } + return -1; + } + + if (!SpellResRef[0]) { + SetSpellResRef(SpellRef); + } + LastTargetPos = target->Pos; if (target->Type==ST_ACTOR) { LastTarget = target->GetGlobalID(); } - return SpellCast(SpellResRef, instant); -} -//start spellcasting (common part) -int Scriptable::SpellCast(const ieResRef SpellResRef, bool instant) -{ - Spell* spl = gamedata->GetSpell( SpellResRef ); - if (!spl) { - SpellHeader = -1; + if(!CheckWildSurge()) { return -1; } + return SpellCast(instant); +} + +static EffectRef fx_force_surge_modifier_ref={"ForceSurgeModifier",NULL,-1}; + +//start spellcasting (common part) +int Scriptable::SpellCast(bool instant) +{ + Spell* spl = gamedata->GetSpell(SpellResRef); // this was checked before we got here + Actor *actor = NULL; if (Type == ST_ACTOR) { - Actor *actor = (Actor *) this; + actor = (Actor *) this; + //The ext. index is here to calculate the casting time - int level = actor->GetXPLevel(true); - //Add casting level bonus/penalty - from stats and LVLMODWM.2da - level += actor->CastingLevelBonus(level, spl->SpellType); + int level = actor->GetCasterLevel(spl->SpellType); SpellHeader = spl->GetHeaderIndexFromLevel(level); } else { SpellHeader = 0; @@ -791,9 +1038,9 @@ int Scriptable::SpellCast(const ieResRef SpellResRef, bool instant) SPLExtHeader *header = spl->GetExtHeader(SpellHeader); int casting_time = (int)header->CastingTime; // how does this work for non-actors exactly? - if (Type == ST_ACTOR) { + if (actor) { // The mental speed effect can shorten or lengthen the casting time. - casting_time -= (int)((Actor *) this)->Modified[IE_MENTALSPEED]; + casting_time -= (int)actor->Modified[IE_MENTALSPEED]; if (casting_time < 0) casting_time = 0; } // this is a guess which seems approximately right so far @@ -801,10 +1048,8 @@ int Scriptable::SpellCast(const ieResRef SpellResRef, bool instant) if (instant) { duration = 0; } - - //cfb - if (Type == ST_ACTOR) { - Actor *actor = (Actor *) this; + if (actor) { + //cfb EffectQueue *fxqueue = spl->GetEffectBlock(this, this->Pos, -1); fxqueue->SetOwner(actor); if (!actor->Modified[IE_AVATARREMOVAL]) { @@ -812,12 +1057,177 @@ int Scriptable::SpellCast(const ieResRef SpellResRef, bool instant) } fxqueue->AddAllEffects(actor, actor->Pos); delete fxqueue; + actor->WMLevelMod = 0; + if (actor->Modified[IE_FORCESURGE] == 1) { + // affects only the next spell cast, but since the timing is permanent, + // we have to remove it manually + actor->fxqueue.RemoveAllEffectsWithParam(fx_force_surge_modifier_ref, 1); + } } gamedata->FreeSpell(spl, SpellResRef, false); return duration; } +// Anyone with some wildness has 5% chance of getting a wild surge when casting, +// but most innates are excluded, due to being nonmagic. +// A d100 roll is made, some stat boni are added, then either: +// 1. the spell is cast normally (score of 100 or more) +// 2. one or more wild surges happen and something else is cast +// 2.1. this can loop, since some surges cause rerolls +int Scriptable::CheckWildSurge() +{ + if (Type != ST_ACTOR || core->HasFeature(GF_3ED_RULES)) { + return 1; + } + Actor *caster = (Actor *) this; + + int roll = core->Roll(1, 100, 0); + if ((roll <= 5 && caster->Modified[IE_SURGEMOD]) || caster->Modified[IE_FORCESURGE]) { + Spell *spl = gamedata->GetSpell( SpellResRef ); // this was checked before we got here + // ignore non-magic "spells" + if (!(spl->Flags&SF_HLA)) { + int check = roll + caster->GetCasterLevel(spl->SpellType) + caster->Modified[IE_SURGEMOD]; + // hundred or more means a normal cast + if (check < 100) { + // display feedback: Wild Surge: bla bla + char text[200]; + snprintf(text, 200, "%s %s", core->GetString(displaymsg->GetStringReference(STR_WILDSURGE), 0), core->GetString(core->SurgeSpells[check-1].message, 0)); + displaymsg->DisplayStringName(text, 0xffffff, this); + + // lookup the spell in the "check" row of wildmag.2da + ieResRef surgeSpellRef; + memset(surgeSpellRef, 0, sizeof(surgeSpellRef)); + strncpy(surgeSpellRef, core->SurgeSpells[check-1].spell, 8); + + Spell *surgeSpell = gamedata->GetSpell(surgeSpellRef); + if (!surgeSpell) { + // handle the hardcoded cases - they'll also fail here + if (!HandleHardcodedSurge(surgeSpellRef, spl, caster)) { + return 0; + } + } else { + // finally change the spell + // the hardcoded bunch does it on its own when needed + strncpy(SpellResRef, surgeSpellRef, 8); + } + } + } + } + + return 1; +} + +bool Scriptable::HandleHardcodedSurge(ieResRef surgeSpellRef, Spell *spl, Actor *caster) +{ + // format: ID or ID.param1 or +SPELLREF + int types = caster->spellbook.GetTypes(); + int lvl = spl->SpellLevel-1; + int count, i, tmp, tmp2, tmp3; + Scriptable *target = NULL; + Point targetpos(-1, -1); + ieResRef newspl; + switch (surgeSpellRef[0]) { + case '+': // cast normally, but also cast SPELLREF first + core->ApplySpell(surgeSpellRef+1, caster, caster, caster->GetCasterLevel(spl->SpellType)); + break; + case '0': // cast spell param1 times + strtok(surgeSpellRef,"."); + count = strtol(strtok(NULL,"."), NULL, 0); + caster->wildSurgeMods.num_castings = count; + break; + case '1': // change projectile (id) to param1 + strtok(surgeSpellRef,"."); + count = strtol(strtok(NULL,"."), NULL, 0); + caster->wildSurgeMods.projectile_id = count; + break; + case '2': // also target target type param1 + strtok(surgeSpellRef,"."); + count = strtol(strtok(NULL,"."), NULL, 0); + caster->wildSurgeMods.target_type = count; + caster->wildSurgeMods.target_change_type = WSTC_ADDTYPE; + break; + case '3': // (wild surge) roll param1 more times + strtok(surgeSpellRef,"."); + count = strtol(strtok(NULL,"."), NULL, 0); + // force surge and then cast + // force the surge roll to be < 100, so we cast a spell from the surge table + tmp = caster->Modified[IE_FORCESURGE]; + tmp2 = caster->Modified[IE_SURGEMOD]; + tmp3 = caster->WMLevelMod; // also save caster level; the original didn't reroll the bonus + caster->Modified[IE_FORCESURGE] = 7; + caster->Modified[IE_SURGEMOD] = - caster->GetCasterLevel(spl->SpellType); // nulify the bonus + if (LastTarget) { + target = area->GetActorByGlobalID(LastTarget); + if (!target) { + target = core->GetGame()->GetActorByGlobalID(LastTarget); + } + } + if (!LastTargetPos.isempty()) { + targetpos = LastTargetPos; + } else if (target) { + targetpos = target->Pos; + } + for (i=0; iCastSpell(SpellResRef, target, false, true); + strncpy(newspl, SpellResRef, 8); + caster->WMLevelMod = tmp3; + caster->CastSpellEnd(); + } else { + caster->CastSpellPoint(SpellResRef, targetpos, false, true); + strncpy(newspl, SpellResRef, 8); + caster->WMLevelMod = tmp3; + caster->CastSpellPointEnd(); + } + // reset the ref, since CastSpell*End destroyed it + strncpy(SpellResRef, newspl, 8); + } + caster->Modified[IE_FORCESURGE] = tmp; + caster->Modified[IE_SURGEMOD] = tmp2; + break; + case '4': // change the target type to param1 + strtok(surgeSpellRef,"."); + count = strtol(strtok(NULL,"."), NULL, 0); + caster->wildSurgeMods.target_type = count; + caster->wildSurgeMods.target_change_type = WSTC_SETTYPE; + break; + case '5': // change the target to a random actor + caster->wildSurgeMods.target_change_type = WSTC_RANDOMIZE; + break; + case '6': // change saving throw (+param1) + strtok(surgeSpellRef,"."); + count = strtol(strtok(NULL,"."), NULL, 0); + caster->wildSurgeMods.saving_throw_mod = count; + break; + case '7': // random spell of the same level (FIXME: make an effect out of this?) + // change this if we ever want the surges to respect the original type + for (i=0; ispellbook.GetKnownSpellsCount(i, lvl); + if (!spellCount) continue; + int id = core->Roll(1, spellCount, -1); + CREKnownSpell *ck = caster->spellbook.GetKnownSpell(i, lvl, id); + if (ck) { + strncpy(SpellResRef, ck->SpellResRef, 8); + break; + } + } + break; + case '8': // set projectile speed to param1 % + strtok(surgeSpellRef,"."); + count = strtol(strtok(NULL,"."), NULL, 0); + caster->wildSurgeMods.projectile_speed_mod = count; + break; + default: + SpellHeader = -1; + SpellResRef[0] = 0; + printMessage("Scriptable", "New spell not found, aborting cast mid-surge!\n", LIGHT_RED); + caster->SetStance(IE_ANI_READY); + return false; + } + return true; +} + bool Scriptable::TimerActive(ieDword ID) { if (ID>=MAX_TIMER) { @@ -989,7 +1399,7 @@ void Selectable::SetCircle(int circlesize, const Color &color, Sprite2D* normal_ int Selectable::WantDither() { //if dithering is disabled globally, don't do it - if (core->FogOfWar&4) { + if (core->FogOfWar&FOG_DITHERSPRITES) { return 0; } //if actor is dead, dither it if polygon wants @@ -1583,8 +1993,8 @@ Door::~Door(void) void Door::ImpedeBlocks(int count, Point *points, unsigned char value) { for(int i = 0;iSearchMap->GetAt( points[i].x, points[i].y ) & PATH_MAP_NOTDOOR; - area->SearchMap->SetAt( points[i].x, points[i].y, (tmp|value) ); + unsigned char tmp = area->GetInternalSearchMap(points[i].x, points[i].y) & PATH_MAP_NOTDOOR; + area->SetInternalSearchMap(points[i].x, points[i].y, tmp|value); } } @@ -1708,7 +2118,7 @@ bool Door::BlockedOpen(int Open, int ForceOpen) Actor** ab; rgn.x = points[i].x*16; rgn.y = points[i].y*12; - unsigned char tmp = area->SearchMap->GetAt( points[i].x, points[i].y ) & PATH_MAP_ACTOR; + unsigned char tmp = area->GetInternalSearchMap(points[i].x, points[i].y) & PATH_MAP_ACTOR; if (tmp) { int ac = area->GetActorInRect(ab, rgn, false); while(ac--) { @@ -2040,10 +2450,7 @@ bool InfoPoint::TriggerTrap(int skill, ieDword ID) bool InfoPoint::Entered(Actor *actor) { if (outline->PointIn( actor->Pos ) ) { - //don't trigger again for this actor - if (!(actor->GetInternalFlag()&IF_INTRAP)) { - goto check; - } + goto check; } // why is this here? actors which aren't *in* a trap get IF_INTRAP // repeatedly unset, so this triggers again and again and again. @@ -2071,6 +2478,10 @@ check: return true; } + if (actor->GetInternalFlag()&IF_INTRAP) { + return false; + } + if (actor->InParty || (Flags&TRAP_NPC) ) { //no need to avoid a travel trigger diff --git a/project/jni/application/gemrb/src/core/Scriptable/ActorBlock.h b/project/jni/application/gemrb/gemrb/core/Scriptable/ActorBlock.h similarity index 95% rename from project/jni/application/gemrb/src/core/Scriptable/ActorBlock.h rename to project/jni/application/gemrb/gemrb/core/Scriptable/ActorBlock.h index b93713b95..72945e8db 100644 --- a/project/jni/application/gemrb/src/core/Scriptable/ActorBlock.h +++ b/project/jni/application/gemrb/gemrb/core/Scriptable/ActorBlock.h @@ -26,6 +26,7 @@ #include "CharAnimations.h" #include "Inventory.h" #include "PathFinder.h" +#include "Spell.h" // for HandleHardcodedSurge (repeat the spell lookup if this header is unwanted) #include "Sprite2D.h" #include "TileOverlay.h" #include "Variables.h" @@ -209,6 +210,7 @@ public: ieDword LastCasterSeen; //Last spellcaster seen Point LastTargetPos; int SpellHeader; + ieResRef SpellResRef; public: /** Gets the Dialog ResRef */ const char* GetDialog(void) const @@ -219,6 +221,7 @@ public: strnuprcpy(Dialog, resref, 8); } void SetScript(const ieResRef aScript, int idx, bool ai=false); + void SetSpellResRef(ieResRef resref); void SetWait(unsigned long time); unsigned long GetWait() const; void LeaveDialog(); @@ -260,12 +263,16 @@ public: void AddTrigger(ieDword *actorref); /* re/draws overhead text on the map screen */ void DrawOverheadText(const Region &screen); + /* check if casting is allowed at all */ + int CanCast(const ieResRef SpellResRef); + /* check for and trigger a wild surge */ + int CheckWildSurge(); /* actor/scriptable casts spell */ - int CastSpellPoint( const ieResRef SpellResRef, const Point &Target, bool deplete, bool instant = false ); - int CastSpell( const ieResRef SpellResRef, Scriptable* Target, bool deplete, bool instant = false ); + int CastSpellPoint( ieResRef &SpellRef, const Point &Target, bool deplete, bool instant = false ); + int CastSpell( ieResRef &SpellRef, Scriptable* Target, bool deplete, bool instant = false ); /* spellcasting finished */ - void CastSpellPointEnd( const ieResRef SpellResRef); - void CastSpellEnd( const ieResRef SpellResRef); + void CastSpellPointEnd(); + void CastSpellEnd(); ieDword GetGlobalID() const { return globalID; } /** timer functions (numeric ID, not saved) */ bool TimerActive(ieDword ID); @@ -274,9 +281,11 @@ public: virtual char* GetName(int /*which*/) const { return NULL; } private: /* used internally to handle start of spellcasting */ - int SpellCast(const ieResRef SpellResRef, bool instant); + int SpellCast(bool instant); /* also part of the spellcasting process, creating the projectile */ void CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool fake); + /* do some magic for the wierd/awesome wild surges */ + bool HandleHardcodedSurge(ieResRef surgeSpellRef, Spell *spl, Actor *caster); }; class GEM_EXPORT Selectable : public Scriptable { diff --git a/project/jni/application/gemrb/src/core/Scriptable/PCStatStruct.cpp b/project/jni/application/gemrb/gemrb/core/Scriptable/PCStatStruct.cpp similarity index 89% rename from project/jni/application/gemrb/src/core/Scriptable/PCStatStruct.cpp rename to project/jni/application/gemrb/gemrb/core/Scriptable/PCStatStruct.cpp index a17359b6a..32338e52d 100644 --- a/project/jni/application/gemrb/src/core/Scriptable/PCStatStruct.cpp +++ b/project/jni/application/gemrb/gemrb/core/Scriptable/PCStatStruct.cpp @@ -151,22 +151,6 @@ void PCStatsStruct::InitQuickSlot(unsigned int which, int slot, int headerindex) } } -/* this function is obsolete, use initquickslot with slot=-1 -void PCStatsStruct::SetSlotIndex(unsigned int which, ieWord headerindex) -{ - //this is not correct, not the slot, but a separate headerindex should be here - switch(which) { - case ACT_QSLOT1: QuickItemHeaders[0]=headerindex; return; - case ACT_QSLOT2: QuickItemHeaders[1]=headerindex; return; - case ACT_QSLOT3: QuickItemHeaders[2]=headerindex; return; - case ACT_QSLOT4: QuickItemHeaders[3]=headerindex; return; - case ACT_QSLOT5: QuickItemHeaders[4]=headerindex; return; - } - ///it shouldn't reach this point - abort(); -} -*/ - //returns both the inventory slot and the header index associated to a quickslot void PCStatsStruct::GetSlotAndIndex(unsigned int which, ieWord &slot, ieWord &headerindex) { diff --git a/project/jni/application/gemrb/src/core/Scriptable/PCStatStruct.h b/project/jni/application/gemrb/gemrb/core/Scriptable/PCStatStruct.h similarity index 97% rename from project/jni/application/gemrb/src/core/Scriptable/PCStatStruct.h rename to project/jni/application/gemrb/gemrb/core/Scriptable/PCStatStruct.h index 2ebd877df..f081f585e 100644 --- a/project/jni/application/gemrb/src/core/Scriptable/PCStatStruct.h +++ b/project/jni/application/gemrb/gemrb/core/Scriptable/PCStatStruct.h @@ -88,6 +88,7 @@ public: ieWord FavouriteWeaponsCount[MAX_FAVOURITES]; ieResRef SoundSet; char SoundFolder[SOUNDFOLDERSIZE]; + ieDword ExtraSettings[16]; //iwd2 - expertise, hamstring, arterial strike, etc ieResRef QuickSpells[MAX_QSLOTS]; //iwd2 uses 9, others use only 3 ieWord QuickWeaponSlots[MAX_QUICKWEAPONSLOT]; //iwd2 uses 8, others use only 4 ieWord QuickWeaponHeaders[MAX_QUICKWEAPONSLOT]; diff --git a/project/jni/application/gemrb/src/core/ScriptedAnimation.cpp b/project/jni/application/gemrb/gemrb/core/ScriptedAnimation.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/ScriptedAnimation.cpp rename to project/jni/application/gemrb/gemrb/core/ScriptedAnimation.cpp diff --git a/project/jni/application/gemrb/src/core/ScriptedAnimation.h b/project/jni/application/gemrb/gemrb/core/ScriptedAnimation.h similarity index 100% rename from project/jni/application/gemrb/src/core/ScriptedAnimation.h rename to project/jni/application/gemrb/gemrb/core/ScriptedAnimation.h diff --git a/project/jni/application/gemrb/src/core/SoundMgr.cpp b/project/jni/application/gemrb/gemrb/core/SoundMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/SoundMgr.cpp rename to project/jni/application/gemrb/gemrb/core/SoundMgr.cpp diff --git a/project/jni/application/gemrb/src/core/SoundMgr.h b/project/jni/application/gemrb/gemrb/core/SoundMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/SoundMgr.h rename to project/jni/application/gemrb/gemrb/core/SoundMgr.h diff --git a/project/jni/application/gemrb/src/core/Spell.cpp b/project/jni/application/gemrb/gemrb/core/Spell.cpp similarity index 90% rename from project/jni/application/gemrb/src/core/Spell.cpp rename to project/jni/application/gemrb/gemrb/core/Spell.cpp index e35820e8f..c7eec2698 100644 --- a/project/jni/application/gemrb/src/core/Spell.cpp +++ b/project/jni/application/gemrb/gemrb/core/Spell.cpp @@ -155,6 +155,17 @@ EffectQueue *Spell::GetEffectBlock(Scriptable *self, const Point &pos, int block fx->InventorySlot = 0xffff; //the hostile flag is used to determine if this was an attack fx->SourceFlags = Flags; + + // apply the stat-based spell duration modifier + if (self->Type == ST_ACTOR) { + Actor *caster = (Actor *) self; + if (caster->Modified[IE_SPELLDURATIONMODMAGE] && SpellType == IE_SPL_WIZARD) { + fx->Duration = (fx->Duration * caster->Modified[IE_SPELLDURATIONMODMAGE]) / 100; + } else if (caster->Modified[IE_SPELLDURATIONMODPRIEST] && SpellType == IE_SPL_PRIEST) { + fx->Duration = (fx->Duration * caster->Modified[IE_SPELLDURATIONMODPRIEST]) / 100; + } + } + if (fx->Target != FX_TARGET_SELF) { fx->Projectile = pro; fxqueue->AddEffect( fx ); @@ -203,24 +214,7 @@ unsigned int Spell::GetCastingDistance(Scriptable *Sender) const Actor *actor = NULL; if (Sender && Sender->Type==ST_ACTOR) { actor = (Actor *) Sender; - } - - if (actor) { - if (SpellType==IE_SPL_WIZARD) { - level = actor->GetMageLevel(); - if (!level) level = actor->GetSorcererLevel(); - if (!level) level = actor->GetBardLevel(); - if (!level) level = actor->GetStat(IE_LEVEL); - level+=actor->GetStat(IE_CASTINGLEVELBONUSMAGE); - } - else if (SpellType==IE_SPL_PRIEST) { - level = actor->GetClericLevel(); - if (!level) level = actor->GetDruidLevel(); - if (!level) level = actor->GetPaladinLevel(); - if (!level) level = actor->GetRangerLevel(); - if (!level) level = actor->GetStat(IE_LEVEL); - level += actor->GetStat(IE_CASTINGLEVELBONUSCLERIC); - } + level = actor->GetCasterLevel(SpellType); } if (level<1) { diff --git a/project/jni/application/gemrb/src/core/Spell.h b/project/jni/application/gemrb/gemrb/core/Spell.h similarity index 100% rename from project/jni/application/gemrb/src/core/Spell.h rename to project/jni/application/gemrb/gemrb/core/Spell.h diff --git a/project/jni/application/gemrb/src/core/SpellMgr.cpp b/project/jni/application/gemrb/gemrb/core/SpellMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/SpellMgr.cpp rename to project/jni/application/gemrb/gemrb/core/SpellMgr.cpp diff --git a/project/jni/application/gemrb/src/core/SpellMgr.h b/project/jni/application/gemrb/gemrb/core/SpellMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/SpellMgr.h rename to project/jni/application/gemrb/gemrb/core/SpellMgr.h diff --git a/project/jni/application/gemrb/src/core/Spellbook.cpp b/project/jni/application/gemrb/gemrb/core/Spellbook.cpp similarity index 92% rename from project/jni/application/gemrb/src/core/Spellbook.cpp rename to project/jni/application/gemrb/gemrb/core/Spellbook.cpp index 1a1c64b93..b910faf67 100644 --- a/project/jni/application/gemrb/src/core/Spellbook.cpp +++ b/project/jni/application/gemrb/gemrb/core/Spellbook.cpp @@ -891,6 +891,80 @@ SpellExtHeader *Spellbook::FindSpellInfo(unsigned int level, unsigned int type, return NULL; } +void Spellbook::AddSpellInfo(unsigned int sm_level, unsigned int sm_type, const ieResRef spellname, unsigned int idx) +{ + Spell *spl = gamedata->GetSpell(spellname); + if (!spl) + return; + if (spl->ExtHeaderCount<1) + return; + + ieDword level = 0; + SpellExtHeader *seh = FindSpellInfo(sm_level, sm_type, spellname); + if (seh) { + seh->count++; + return; + } + + seh = new SpellExtHeader; + spellinfo.push_back( seh ); + + memcpy(seh->spellname, spellname, sizeof(ieResRef) ); + int ehc; + + for (ehc = 0; ehc < spl->ExtHeaderCount-1; ehc++) { + if (levelext_headers[ehc+1].RequiredLevel) { + break; + } + } + + SPLExtHeader *ext_header = spl->ext_headers+ehc; + seh->headerindex = ehc; + seh->level = sm_level; + seh->type = sm_type; + seh->slot = idx; + seh->count = 1; + seh->SpellForm = ext_header->SpellForm; + memcpy(seh->MemorisedIcon, ext_header->MemorisedIcon,sizeof(ieResRef) ); + seh->Target = ext_header->Target; + seh->TargetNumber = ext_header->TargetNumber; + seh->Range = ext_header->Range; + seh->Projectile = ext_header->ProjectileAnimation; + seh->CastingTime = (ieWord) ext_header->CastingTime; + seh->strref = spl->SpellName; + gamedata->FreeSpell(spl, spellname, false); +} + +void Spellbook::SetCustomSpellInfo(ieResRef *data, ieResRef spell, int type) +{ + ClearSpellInfo(); + if (data) { + for(int i = 0; iknown_spells.size(); k++) { + CREKnownSpell* slot = sm->known_spells[k]; + if (!slot) + continue; + //skip the spell itself + if (!strnicmp(slot->SpellResRef, spell, sizeof(ieResRef))) + continue; + AddSpellInfo(sm->Level, sm->Type, slot->SpellResRef, -1); + } + } + } + } +} + // grouping the castable spells void Spellbook::GenerateSpellInfo() { @@ -905,41 +979,7 @@ void Spellbook::GenerateSpellInfo() continue; if (!slot->Flags) continue; - Spell *spl = gamedata->GetSpell(slot->SpellResRef); - if (!spl) - continue; - ieDword level = 0; - SpellExtHeader *seh = FindSpellInfo(sm->Level, sm->Type, slot->SpellResRef); - if (seh) { - seh->count++; - continue; - } - seh = new SpellExtHeader; - spellinfo.push_back( seh ); - - memcpy(seh->spellname, slot->SpellResRef, sizeof(ieResRef) ); - int ehc; - - for (ehc = 0; ehc < spl->ExtHeaderCount-1; ehc++) { - if (levelext_headers[ehc+1].RequiredLevel) { - break; - } - } - SPLExtHeader *ext_header = spl->ext_headers+ehc; - seh->headerindex = ehc; - seh->level = sm->Level; - seh->type = sm->Type; - seh->slot = k; - seh->count = 1; - seh->SpellForm = ext_header->SpellForm; - memcpy(seh->MemorisedIcon, ext_header->MemorisedIcon,sizeof(ieResRef) ); - seh->Target = ext_header->Target; - seh->TargetNumber = ext_header->TargetNumber; - seh->Range = ext_header->Range; - seh->Projectile = ext_header->ProjectileAnimation; - seh->CastingTime = (ieWord) ext_header->CastingTime; - seh->strref = spl->SpellName; - gamedata->FreeSpell(spl, slot->SpellResRef, false); + AddSpellInfo(sm->Level, sm->Type, slot->SpellResRef, k); } } } @@ -953,12 +993,6 @@ void Spellbook::dump() for (int i = 0; i < NUM_BOOK_TYPES; i++) { for (unsigned int j = 0; j < spells[i].size(); j++) { CRESpellMemorization* sm = spells[i][j]; - //if (!sm || !sm->Number) continue; - //if (!sm) continue; - - //Never ever use field length qualifiers it is not portable, if you need to convert, convert to compatible values, anyway we don't need this! - //printf ( "type: %d: L: %d; N1: %d; N2: %d; T: %d; KC: %d; MC: %d\n", i, - // sm->Level, sm->Number, sm->Number2, sm->Type, (int) sm->known_spells.size(), (int) sm->memorized_spells.size() ); if (sm->known_spells.size()) printf( " Known spells:\n" ); diff --git a/project/jni/application/gemrb/src/core/Spellbook.h b/project/jni/application/gemrb/gemrb/core/Spellbook.h similarity index 96% rename from project/jni/application/gemrb/src/core/Spellbook.h rename to project/jni/application/gemrb/gemrb/core/Spellbook.h index 3a65b775f..fb24516d7 100644 --- a/project/jni/application/gemrb/src/core/Spellbook.h +++ b/project/jni/application/gemrb/gemrb/core/Spellbook.h @@ -138,10 +138,10 @@ private: bool DepleteSpell(CREMemorizedSpell* spl); /** Depletes a sorcerer type spellpage by one */ void DepleteLevel(CRESpellMemorization* sm); + /** Adds a single spell to the spell info list */ + void AddSpellInfo(unsigned int level, unsigned int type, const ieResRef name, unsigned int idx); /** regenerates the spellinfo list */ void GenerateSpellInfo(); - /** invalidates the spellinfo list */ - void ClearSpellInfo(); /** looks up the spellinfo list for an element */ SpellExtHeader *FindSpellInfo(unsigned int level, unsigned int type, const ieResRef name); /** removes all instances of a spell from a given page */ @@ -232,6 +232,12 @@ public: /** returns the number of distinct spells (generates spellinfo) */ unsigned int GetSpellInfoSize(int type); + /** generates a custom spellinfo list for fx_select_spell */ + void SetCustomSpellInfo(ieResRef *data, ieResRef spell, int type); + + /** invalidates the spellinfo list */ + void ClearSpellInfo(); + /** lists spells of a type */ bool GetSpellInfo(SpellExtHeader *array, int type, int startindex, int count); /** Dumps spellbook to stdout for debugging */ diff --git a/project/jni/application/gemrb/src/core/Sprite2D.cpp b/project/jni/application/gemrb/gemrb/core/Sprite2D.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Sprite2D.cpp rename to project/jni/application/gemrb/gemrb/core/Sprite2D.cpp diff --git a/project/jni/application/gemrb/src/core/Sprite2D.h b/project/jni/application/gemrb/gemrb/core/Sprite2D.h similarity index 100% rename from project/jni/application/gemrb/src/core/Sprite2D.h rename to project/jni/application/gemrb/gemrb/core/Sprite2D.h diff --git a/project/jni/application/gemrb/src/core/SpriteCover.cpp b/project/jni/application/gemrb/gemrb/core/SpriteCover.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/SpriteCover.cpp rename to project/jni/application/gemrb/gemrb/core/SpriteCover.cpp diff --git a/project/jni/application/gemrb/src/core/SpriteCover.h b/project/jni/application/gemrb/gemrb/core/SpriteCover.h similarity index 100% rename from project/jni/application/gemrb/src/core/SpriteCover.h rename to project/jni/application/gemrb/gemrb/core/SpriteCover.h diff --git a/project/jni/application/gemrb/src/core/Store.cpp b/project/jni/application/gemrb/gemrb/core/Store.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Store.cpp rename to project/jni/application/gemrb/gemrb/core/Store.cpp diff --git a/project/jni/application/gemrb/src/core/Store.h b/project/jni/application/gemrb/gemrb/core/Store.h similarity index 100% rename from project/jni/application/gemrb/src/core/Store.h rename to project/jni/application/gemrb/gemrb/core/Store.h diff --git a/project/jni/application/gemrb/src/core/StoreMgr.cpp b/project/jni/application/gemrb/gemrb/core/StoreMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/StoreMgr.cpp rename to project/jni/application/gemrb/gemrb/core/StoreMgr.cpp diff --git a/project/jni/application/gemrb/src/core/StoreMgr.h b/project/jni/application/gemrb/gemrb/core/StoreMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/StoreMgr.h rename to project/jni/application/gemrb/gemrb/core/StoreMgr.h diff --git a/project/jni/application/gemrb/src/core/StringMgr.cpp b/project/jni/application/gemrb/gemrb/core/StringMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/StringMgr.cpp rename to project/jni/application/gemrb/gemrb/core/StringMgr.cpp diff --git a/project/jni/application/gemrb/src/core/StringMgr.h b/project/jni/application/gemrb/gemrb/core/StringMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/StringMgr.h rename to project/jni/application/gemrb/gemrb/core/StringMgr.h diff --git a/project/jni/application/gemrb/src/core/SymbolMgr.cpp b/project/jni/application/gemrb/gemrb/core/SymbolMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/SymbolMgr.cpp rename to project/jni/application/gemrb/gemrb/core/SymbolMgr.cpp diff --git a/project/jni/application/gemrb/src/core/SymbolMgr.h b/project/jni/application/gemrb/gemrb/core/SymbolMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/SymbolMgr.h rename to project/jni/application/gemrb/gemrb/core/SymbolMgr.h diff --git a/project/jni/application/gemrb/src/core/System/CachedFileStream.cpp b/project/jni/application/gemrb/gemrb/core/System/CachedFileStream.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/System/CachedFileStream.cpp rename to project/jni/application/gemrb/gemrb/core/System/CachedFileStream.cpp diff --git a/project/jni/application/gemrb/src/core/System/CachedFileStream.h b/project/jni/application/gemrb/gemrb/core/System/CachedFileStream.h similarity index 100% rename from project/jni/application/gemrb/src/core/System/CachedFileStream.h rename to project/jni/application/gemrb/gemrb/core/System/CachedFileStream.h diff --git a/project/jni/application/gemrb/src/core/System/DataStream.cpp b/project/jni/application/gemrb/gemrb/core/System/DataStream.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/System/DataStream.cpp rename to project/jni/application/gemrb/gemrb/core/System/DataStream.cpp diff --git a/project/jni/application/gemrb/src/core/System/DataStream.h b/project/jni/application/gemrb/gemrb/core/System/DataStream.h similarity index 100% rename from project/jni/application/gemrb/src/core/System/DataStream.h rename to project/jni/application/gemrb/gemrb/core/System/DataStream.h diff --git a/project/jni/application/gemrb/src/core/System/FileStream.cpp b/project/jni/application/gemrb/gemrb/core/System/FileStream.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/System/FileStream.cpp rename to project/jni/application/gemrb/gemrb/core/System/FileStream.cpp diff --git a/project/jni/application/gemrb/src/core/System/FileStream.h b/project/jni/application/gemrb/gemrb/core/System/FileStream.h similarity index 100% rename from project/jni/application/gemrb/src/core/System/FileStream.h rename to project/jni/application/gemrb/gemrb/core/System/FileStream.h diff --git a/project/jni/application/gemrb/src/core/System/MemoryStream.cpp b/project/jni/application/gemrb/gemrb/core/System/MemoryStream.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/System/MemoryStream.cpp rename to project/jni/application/gemrb/gemrb/core/System/MemoryStream.cpp diff --git a/project/jni/application/gemrb/src/core/System/MemoryStream.h b/project/jni/application/gemrb/gemrb/core/System/MemoryStream.h similarity index 100% rename from project/jni/application/gemrb/src/core/System/MemoryStream.h rename to project/jni/application/gemrb/gemrb/core/System/MemoryStream.h diff --git a/project/jni/application/gemrb/src/core/System/VFS.cpp b/project/jni/application/gemrb/gemrb/core/System/VFS.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/System/VFS.cpp rename to project/jni/application/gemrb/gemrb/core/System/VFS.cpp diff --git a/project/jni/application/gemrb/src/core/System/VFS.h b/project/jni/application/gemrb/gemrb/core/System/VFS.h similarity index 100% rename from project/jni/application/gemrb/src/core/System/VFS.h rename to project/jni/application/gemrb/gemrb/core/System/VFS.h diff --git a/project/jni/application/gemrb/src/core/System/swab.c b/project/jni/application/gemrb/gemrb/core/System/swab.c similarity index 100% rename from project/jni/application/gemrb/src/core/System/swab.c rename to project/jni/application/gemrb/gemrb/core/System/swab.c diff --git a/project/jni/application/gemrb/src/core/System/swab.h b/project/jni/application/gemrb/gemrb/core/System/swab.h similarity index 99% rename from project/jni/application/gemrb/src/core/System/swab.h rename to project/jni/application/gemrb/gemrb/core/System/swab.h index 39dfdb55a..8788ad7b9 100644 --- a/project/jni/application/gemrb/src/core/System/swab.h +++ b/project/jni/application/gemrb/gemrb/core/System/swab.h @@ -25,7 +25,7 @@ extern "C" { #ifndef _SSIZE_T_DEFINED_ # define _SSIZE_T_DEFINED_ typedef long int ssize_t; -#endif +#endif void swab(const void *bfrom, void *bto, ssize_t n); diff --git a/project/jni/application/gemrb/src/core/TableMgr.cpp b/project/jni/application/gemrb/gemrb/core/TableMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/TableMgr.cpp rename to project/jni/application/gemrb/gemrb/core/TableMgr.cpp diff --git a/project/jni/application/gemrb/src/core/TableMgr.h b/project/jni/application/gemrb/gemrb/core/TableMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/TableMgr.h rename to project/jni/application/gemrb/gemrb/core/TableMgr.h diff --git a/project/jni/application/gemrb/src/core/Tile.cpp b/project/jni/application/gemrb/gemrb/core/Tile.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Tile.cpp rename to project/jni/application/gemrb/gemrb/core/Tile.cpp diff --git a/project/jni/application/gemrb/src/core/Tile.h b/project/jni/application/gemrb/gemrb/core/Tile.h similarity index 100% rename from project/jni/application/gemrb/src/core/Tile.h rename to project/jni/application/gemrb/gemrb/core/Tile.h diff --git a/project/jni/application/gemrb/src/core/TileMap.cpp b/project/jni/application/gemrb/gemrb/core/TileMap.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/TileMap.cpp rename to project/jni/application/gemrb/gemrb/core/TileMap.cpp diff --git a/project/jni/application/gemrb/src/core/TileMap.h b/project/jni/application/gemrb/gemrb/core/TileMap.h similarity index 100% rename from project/jni/application/gemrb/src/core/TileMap.h rename to project/jni/application/gemrb/gemrb/core/TileMap.h diff --git a/project/jni/application/gemrb/src/core/TileMapMgr.cpp b/project/jni/application/gemrb/gemrb/core/TileMapMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/TileMapMgr.cpp rename to project/jni/application/gemrb/gemrb/core/TileMapMgr.cpp diff --git a/project/jni/application/gemrb/src/core/TileMapMgr.h b/project/jni/application/gemrb/gemrb/core/TileMapMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/TileMapMgr.h rename to project/jni/application/gemrb/gemrb/core/TileMapMgr.h diff --git a/project/jni/application/gemrb/src/core/TileOverlay.cpp b/project/jni/application/gemrb/gemrb/core/TileOverlay.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/TileOverlay.cpp rename to project/jni/application/gemrb/gemrb/core/TileOverlay.cpp diff --git a/project/jni/application/gemrb/src/core/TileOverlay.h b/project/jni/application/gemrb/gemrb/core/TileOverlay.h similarity index 100% rename from project/jni/application/gemrb/src/core/TileOverlay.h rename to project/jni/application/gemrb/gemrb/core/TileOverlay.h diff --git a/project/jni/application/gemrb/src/core/TileSetMgr.cpp b/project/jni/application/gemrb/gemrb/core/TileSetMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/TileSetMgr.cpp rename to project/jni/application/gemrb/gemrb/core/TileSetMgr.cpp diff --git a/project/jni/application/gemrb/src/core/TileSetMgr.h b/project/jni/application/gemrb/gemrb/core/TileSetMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/TileSetMgr.h rename to project/jni/application/gemrb/gemrb/core/TileSetMgr.h diff --git a/project/jni/application/gemrb/src/core/TypeID.h b/project/jni/application/gemrb/gemrb/core/TypeID.h similarity index 100% rename from project/jni/application/gemrb/src/core/TypeID.h rename to project/jni/application/gemrb/gemrb/core/TypeID.h diff --git a/project/jni/application/gemrb/src/core/Variables.cpp b/project/jni/application/gemrb/gemrb/core/Variables.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Variables.cpp rename to project/jni/application/gemrb/gemrb/core/Variables.cpp diff --git a/project/jni/application/gemrb/src/core/Variables.h b/project/jni/application/gemrb/gemrb/core/Variables.h similarity index 100% rename from project/jni/application/gemrb/src/core/Variables.h rename to project/jni/application/gemrb/gemrb/core/Variables.h diff --git a/project/jni/application/gemrb/src/core/Video.cpp b/project/jni/application/gemrb/gemrb/core/Video.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/Video.cpp rename to project/jni/application/gemrb/gemrb/core/Video.cpp diff --git a/project/jni/application/gemrb/src/core/Video.h b/project/jni/application/gemrb/gemrb/core/Video.h similarity index 100% rename from project/jni/application/gemrb/src/core/Video.h rename to project/jni/application/gemrb/gemrb/core/Video.h diff --git a/project/jni/application/gemrb/src/core/VideoMode.h b/project/jni/application/gemrb/gemrb/core/VideoMode.h similarity index 100% rename from project/jni/application/gemrb/src/core/VideoMode.h rename to project/jni/application/gemrb/gemrb/core/VideoMode.h diff --git a/project/jni/application/gemrb/src/core/WindowMgr.cpp b/project/jni/application/gemrb/gemrb/core/WindowMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/WindowMgr.cpp rename to project/jni/application/gemrb/gemrb/core/WindowMgr.cpp diff --git a/project/jni/application/gemrb/src/core/WindowMgr.h b/project/jni/application/gemrb/gemrb/core/WindowMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/WindowMgr.h rename to project/jni/application/gemrb/gemrb/core/WindowMgr.h diff --git a/project/jni/application/gemrb/src/core/WorldMap.cpp b/project/jni/application/gemrb/gemrb/core/WorldMap.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/WorldMap.cpp rename to project/jni/application/gemrb/gemrb/core/WorldMap.cpp diff --git a/project/jni/application/gemrb/src/core/WorldMap.h b/project/jni/application/gemrb/gemrb/core/WorldMap.h similarity index 100% rename from project/jni/application/gemrb/src/core/WorldMap.h rename to project/jni/application/gemrb/gemrb/core/WorldMap.h diff --git a/project/jni/application/gemrb/src/core/WorldMapMgr.cpp b/project/jni/application/gemrb/gemrb/core/WorldMapMgr.cpp similarity index 100% rename from project/jni/application/gemrb/src/core/WorldMapMgr.cpp rename to project/jni/application/gemrb/gemrb/core/WorldMapMgr.cpp diff --git a/project/jni/application/gemrb/src/core/WorldMapMgr.h b/project/jni/application/gemrb/gemrb/core/WorldMapMgr.h similarity index 100% rename from project/jni/application/gemrb/src/core/WorldMapMgr.h rename to project/jni/application/gemrb/gemrb/core/WorldMapMgr.h diff --git a/project/jni/application/gemrb/src/core/damages.h b/project/jni/application/gemrb/gemrb/core/damages.h similarity index 100% rename from project/jni/application/gemrb/src/core/damages.h rename to project/jni/application/gemrb/gemrb/core/damages.h diff --git a/project/jni/application/gemrb/src/includes/Makefile.am b/project/jni/application/gemrb/gemrb/includes/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/includes/Makefile.am rename to project/jni/application/gemrb/gemrb/includes/Makefile.am diff --git a/project/jni/application/gemrb/src/includes/RGBAColor.h b/project/jni/application/gemrb/gemrb/includes/RGBAColor.h similarity index 100% rename from project/jni/application/gemrb/src/includes/RGBAColor.h rename to project/jni/application/gemrb/gemrb/includes/RGBAColor.h diff --git a/project/jni/application/gemrb/src/includes/SClassID.h b/project/jni/application/gemrb/gemrb/includes/SClassID.h similarity index 100% rename from project/jni/application/gemrb/src/includes/SClassID.h rename to project/jni/application/gemrb/gemrb/includes/SClassID.h diff --git a/project/jni/application/gemrb/src/includes/defsounds.h b/project/jni/application/gemrb/gemrb/includes/defsounds.h similarity index 100% rename from project/jni/application/gemrb/src/includes/defsounds.h rename to project/jni/application/gemrb/gemrb/includes/defsounds.h diff --git a/project/jni/application/gemrb/src/includes/errors.h b/project/jni/application/gemrb/gemrb/includes/errors.h similarity index 100% rename from project/jni/application/gemrb/src/includes/errors.h rename to project/jni/application/gemrb/gemrb/includes/errors.h diff --git a/project/jni/application/gemrb/src/includes/exports.h b/project/jni/application/gemrb/gemrb/includes/exports.h similarity index 100% rename from project/jni/application/gemrb/src/includes/exports.h rename to project/jni/application/gemrb/gemrb/includes/exports.h diff --git a/project/jni/application/gemrb/src/includes/globals.h b/project/jni/application/gemrb/gemrb/includes/globals.h similarity index 98% rename from project/jni/application/gemrb/src/includes/globals.h rename to project/jni/application/gemrb/gemrb/includes/globals.h index 91ade29fd..e4ff5cfef 100644 --- a/project/jni/application/gemrb/src/includes/globals.h +++ b/project/jni/application/gemrb/gemrb/includes/globals.h @@ -146,9 +146,9 @@ #define GF_JOURNAL_HAS_SECTIONS 56 //bg2 #define GF_CASTING_SOUNDS 57 //all except pst and bg1 #define GF_CASTING_SOUNDS2 58 //bg2 - +#define GF_FORCE_AREA_SCRIPT 59 //how and iwd2 (maybe iwd1) //update this or bad things can happen -#define GF_COUNT 59 +#define GF_COUNT 60 //the number of item usage fields (used in CREItem and STOItem) #define CHARGE_COUNTERS 3 diff --git a/project/jni/application/gemrb/src/includes/ie_feats.h b/project/jni/application/gemrb/gemrb/includes/ie_feats.h similarity index 100% rename from project/jni/application/gemrb/src/includes/ie_feats.h rename to project/jni/application/gemrb/gemrb/includes/ie_feats.h diff --git a/project/jni/application/gemrb/src/includes/ie_stats.h b/project/jni/application/gemrb/gemrb/includes/ie_stats.h similarity index 96% rename from project/jni/application/gemrb/src/includes/ie_stats.h rename to project/jni/application/gemrb/gemrb/includes/ie_stats.h index 2404ec356..99e784bd7 100644 --- a/project/jni/application/gemrb/src/includes/ie_stats.h +++ b/project/jni/application/gemrb/gemrb/includes/ie_stats.h @@ -102,10 +102,10 @@ #define STATE_HELPLESS 0x00000020 #define STATE_FROZEN 0x00000040 #define STATE_PETRIFIED 0x00000080 -#define STATE_D3 0x00000100 +#define STATE_EXPLODING 0x00000100 #define STATE_PST_MIRROR 0x00000100 -#define STATE_D4 0x00000200 -#define STATE_D5 0x00000400 +#define STATE_FLAME 0x00000200 +#define STATE_ACID 0x00000400 #define STATE_DEAD 0x00000800 #define STATE_SILENCED 0x00001000 #define STATE_CHARMED 0x00002000 @@ -157,10 +157,21 @@ #define EXTSTATE_EYE_SPIRIT 0x00000100 #define EXTSTATE_EYE_FORT 0x00000200 #define EXTSTATE_EYE_STONE 0x00000400 +#define EXTSTATE_ANIMAL_RAGE 0x00000800 #define EXTSTATE_NO_HP 0x00001000 //disable hp info in berserk mode +#define EXTSTATE_BERSERK 0x00002000 #define EXTSTATE_NO_BACKSTAB 0x00004000 #define EXTSTATE_FLOATTEXTS 0x00008000 //weapon chatting (IWD) +#define EXTSTATE_UNSTUN 0x00010000 //receiving damage will unstun #define EXTSTATE_DEAF 0x00020000 +#define EXTSTATE_CHAOTICCMD 0x00040000 +#define EXTSTATE_MISCAST 0x00080000 +#define EXTSTATE_PAIN 0x00100000 +#define EXTSTATE_MALISON 0x00200000 +#define EXTSTATE_BLOODRAGE 0x00400000 +#define EXTSTATE_CATSGRACE 0x00800000 +#define EXTSTATE_MOLD 0x01000000 +#define EXTSTATE_SHROUD 0x02000000 #define EXTSTATE_NO_WAKEUP 0x80000000 //original HoW engine put this on top of eye_mind #define EXTSTATE_SEVEN_EYES 0x000007f0 diff --git a/project/jni/application/gemrb/src/includes/ie_types.h b/project/jni/application/gemrb/gemrb/includes/ie_types.h similarity index 100% rename from project/jni/application/gemrb/src/includes/ie_types.h rename to project/jni/application/gemrb/gemrb/includes/ie_types.h diff --git a/project/jni/application/gemrb/src/includes/iless.h b/project/jni/application/gemrb/gemrb/includes/iless.h similarity index 100% rename from project/jni/application/gemrb/src/includes/iless.h rename to project/jni/application/gemrb/gemrb/includes/iless.h diff --git a/project/jni/application/gemrb/src/includes/logging.h b/project/jni/application/gemrb/gemrb/includes/logging.h similarity index 100% rename from project/jni/application/gemrb/src/includes/logging.h rename to project/jni/application/gemrb/gemrb/includes/logging.h diff --git a/project/jni/application/gemrb/src/includes/opcode_params.h b/project/jni/application/gemrb/gemrb/includes/opcode_params.h similarity index 96% rename from project/jni/application/gemrb/src/includes/opcode_params.h rename to project/jni/application/gemrb/gemrb/includes/opcode_params.h index f20d72cf7..081dba684 100644 --- a/project/jni/application/gemrb/src/includes/opcode_params.h +++ b/project/jni/application/gemrb/gemrb/includes/opcode_params.h @@ -42,6 +42,13 @@ #define RPD_WIS 8 #define RPD_CHA 9 #define RPD_SLOW 10 +//HoW specific disease types +#define RPD_MOLD 11 +#define RPD_MOLD2 12 +//iwd2 specific disease types +#define RPD_CONTAGION 13 +#define RPD_PEST 14 +#define RPD_DOLOR 15 //appply spell on condition #define COND_GOTHIT 0 diff --git a/project/jni/application/gemrb/src/includes/operatorbool.h b/project/jni/application/gemrb/gemrb/includes/operatorbool.h similarity index 100% rename from project/jni/application/gemrb/src/includes/operatorbool.h rename to project/jni/application/gemrb/gemrb/includes/operatorbool.h diff --git a/project/jni/application/gemrb/src/includes/overlays.h b/project/jni/application/gemrb/gemrb/includes/overlays.h similarity index 100% rename from project/jni/application/gemrb/src/includes/overlays.h rename to project/jni/application/gemrb/gemrb/includes/overlays.h diff --git a/project/jni/application/gemrb/src/includes/plugindef.h b/project/jni/application/gemrb/gemrb/includes/plugindef.h similarity index 100% rename from project/jni/application/gemrb/src/includes/plugindef.h rename to project/jni/application/gemrb/gemrb/includes/plugindef.h diff --git a/project/jni/application/gemrb/src/includes/strrefs.h b/project/jni/application/gemrb/gemrb/includes/strrefs.h similarity index 75% rename from project/jni/application/gemrb/src/includes/strrefs.h rename to project/jni/application/gemrb/gemrb/includes/strrefs.h index 3764294bc..e960f71c7 100644 --- a/project/jni/application/gemrb/src/includes/strrefs.h +++ b/project/jni/application/gemrb/gemrb/includes/strrefs.h @@ -119,19 +119,19 @@ #define STR_LOCKPICK_FAILED 86 #define STR_STATIC_DISS 87 #define STR_LIGHTNING_DISS 88 -#define STR_UNUSABLEITEM 89 //item has no usable ability -#define STR_ITEMID 90 //item needs identify +#define STR_UNUSABLEITEM 89 //item has no usable ability +#define STR_ITEMID 90 //item needs identify #define STR_WRONGITEMTYPE 91 #define STR_ITEMEXCL 92 -#define STR_PICKPOCKET_DONE 93 //done -#define STR_PICKPOCKET_NONE 94 //no items to steal -#define STR_PICKPOCKET_FAIL 95 //failed, noticed -#define STR_PICKPOCKET_EVIL 96 //can't pick hostiles -#define STR_PICKPOCKET_ARMOR 97 //armor restriction -#define STR_USING_FEAT 98 -#define STR_STOPPED_FEAT 99 -#define STR_DISARM_DONE 100 //trap disarmed -#define STR_DISARM_FAIL 101 //trap not disarmed +#define STR_PICKPOCKET_DONE 93 //done +#define STR_PICKPOCKET_NONE 94 //no items to steal +#define STR_PICKPOCKET_FAIL 95 //failed, noticed +#define STR_PICKPOCKET_EVIL 96 //can't pick hostiles +#define STR_PICKPOCKET_ARMOR 97 //armor restriction +#define STR_USING_FEAT 98 +#define STR_STOPPED_FEAT 99 +#define STR_DISARM_DONE 100 //trap disarmed +#define STR_DISARM_FAIL 101 //trap not disarmed #define STR_DOORBASH_DONE 102 #define STR_DOORBASH_FAIL 103 #define STR_CONTBASH_DONE 104 @@ -158,40 +158,44 @@ #define STR_PST_HOUR 125 #define STR_PST_HOURS 126 #define STR_DAMAGE_IMMUNITY 127 -#define STR_DAMAGE1 128 -#define STR_DAMAGE2 129 -#define STR_DAMAGE3 130 -#define STR_DMG_POISON 131 -#define STR_DMG_MAGIC 132 -#define STR_DMG_MISSILE 133 -#define STR_DMG_SLASHING 134 -#define STR_DMG_PIERCING 135 -#define STR_DMG_CRUSHING 136 -#define STR_DMG_FIRE 137 -#define STR_DMG_ELECTRIC 138 -#define STR_DMG_COLD 139 -#define STR_DMG_ACID 140 -#define STR_DMG_OTHER 141 -#define STR_GOTQUESTXP 142 -#define STR_LEVELUP 143 +#define STR_DAMAGE1 128 +#define STR_DAMAGE2 129 +#define STR_DAMAGE3 130 +#define STR_DMG_POISON 131 +#define STR_DMG_MAGIC 132 +#define STR_DMG_MISSILE 133 +#define STR_DMG_SLASHING 134 +#define STR_DMG_PIERCING 135 +#define STR_DMG_CRUSHING 136 +#define STR_DMG_FIRE 137 +#define STR_DMG_ELECTRIC 138 +#define STR_DMG_COLD 139 +#define STR_DMG_ACID 140 +#define STR_DMG_OTHER 141 +#define STR_GOTQUESTXP 142 +#define STR_LEVELUP 143 #define STR_INVFULL_ITEMDROP 144 -#define STR_CONTDUP 145 -#define STR_CONTTRIG 146 -#define STR_CONTFAIL 147 -#define STR_SEQDUP 148 -#define STR_CRITICAL_HIT 149 +#define STR_CONTDUP 145 +#define STR_CONTTRIG 146 +#define STR_CONTFAIL 147 +#define STR_SEQDUP 148 +#define STR_CRITICAL_HIT 149 #define STR_CRITICAL_MISS 150 -#define STR_DEATH 151 -#define STR_BACKSTAB 152 -#define STR_BACKSTAB_BAD 153 +#define STR_DEATH 151 +#define STR_BACKSTAB 152 +#define STR_BACKSTAB_BAD 153 #define STR_BACKSTAB_FAIL 154 #define STR_CASTER_LVL_INC 155 // caster level bonus (wild mages) #define STR_CASTER_LVL_DEC 156 -#define STR_EXPORTED 157 // characters exported (iwd) -#define STR_PALADIN_FALL 158 -#define STR_RANGER_FALL 159 -#define STR_RES_RESISTED 160 - -#define STRREF_COUNT 161 +#define STR_EXPORTED 157 // characters exported (iwd) +#define STR_PALADIN_FALL 158 +#define STR_RANGER_FALL 159 +#define STR_RES_RESISTED 160 +#define STR_DEADMAGIC_FAIL 161 +#define STR_MISCASTMAGIC 162 +#define STR_WILDSURGE 163 +#define STR_FAMBLOCK 164 +#define STR_FAMPROTAGONIST 165 +#define STRREF_COUNT 166 #endif //! IE_STRINGS_H diff --git a/project/jni/application/gemrb/src/includes/win32def.h b/project/jni/application/gemrb/gemrb/includes/win32def.h similarity index 97% rename from project/jni/application/gemrb/src/includes/win32def.h rename to project/jni/application/gemrb/gemrb/includes/win32def.h index 715d09d75..5b676e090 100644 --- a/project/jni/application/gemrb/src/includes/win32def.h +++ b/project/jni/application/gemrb/gemrb/includes/win32def.h @@ -60,10 +60,6 @@ # define strnicmp strncasecmp #endif //WIN32 -#ifdef ANDROID -# define HAVE_SNPRINTF 1 -#endif - #ifndef HAVE_SNPRINTF # ifdef WIN32 # define snprintf _snprintf diff --git a/project/jni/application/gemrb/gemrb/plugins-prepare.sh b/project/jni/application/gemrb/gemrb/plugins-prepare.sh new file mode 100644 index 000000000..ea3c18ed4 --- /dev/null +++ b/project/jni/application/gemrb/gemrb/plugins-prepare.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# GemRB - Infinity Engine Emulator +# Copyright (C) 2003 The GemRB Project +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# +# link all plugins to the plugin dir, so gemrb can run from the build dir +dir=$1 +if test -z "$dir"; then + cd `dirname $0`/plugins +else + cd "$dir" +fi || return 1 + +if test -d 2DAImporter/.libs; then + ln -sf */.libs/*.so . +else + # cmake; expect to be in the build dir since it is arbitrary + if test -z "$dir"; then + echo missing dir parameter - pass the path to the build dir + exit 1 + fi && + cd gemrb/plugins && + ln -sf */*.so . +fi || return 2 diff --git a/project/jni/application/gemrb/src/plugins/2DAImporter/2DAImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/2DAImporter/2DAImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/2DAImporter/2DAImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/2DAImporter/2DAImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/2DAImporter/2DAImporter.h b/project/jni/application/gemrb/gemrb/plugins/2DAImporter/2DAImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/2DAImporter/2DAImporter.h rename to project/jni/application/gemrb/gemrb/plugins/2DAImporter/2DAImporter.h diff --git a/project/jni/application/gemrb/src/plugins/2DAImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/2DAImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/2DAImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/2DAImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/2DAImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/2DAImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/2DAImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/2DAImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/ACMReader.cpp b/project/jni/application/gemrb/gemrb/plugins/ACMReader/ACMReader.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/ACMReader.cpp rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/ACMReader.cpp diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/ACMReader.h b/project/jni/application/gemrb/gemrb/plugins/ACMReader/ACMReader.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/ACMReader.h rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/ACMReader.h diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/ACMReader/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/ACMReader/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/decoder.cpp b/project/jni/application/gemrb/gemrb/plugins/ACMReader/decoder.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/decoder.cpp rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/decoder.cpp diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/decoder.h b/project/jni/application/gemrb/gemrb/plugins/ACMReader/decoder.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/decoder.h rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/decoder.h diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/general.h b/project/jni/application/gemrb/gemrb/plugins/ACMReader/general.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/general.h rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/general.h diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/unpacker.cpp b/project/jni/application/gemrb/gemrb/plugins/ACMReader/unpacker.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/unpacker.cpp rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/unpacker.cpp diff --git a/project/jni/application/gemrb/src/plugins/ACMReader/unpacker.h b/project/jni/application/gemrb/gemrb/plugins/ACMReader/unpacker.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/ACMReader/unpacker.h rename to project/jni/application/gemrb/gemrb/plugins/ACMReader/unpacker.h diff --git a/project/jni/application/gemrb/src/plugins/AREImporter/AREImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/AREImporter/AREImporter.cpp similarity index 99% rename from project/jni/application/gemrb/src/plugins/AREImporter/AREImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/AREImporter/AREImporter.cpp index 987864657..8d79968f0 100644 --- a/project/jni/application/gemrb/src/plugins/AREImporter/AREImporter.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/AREImporter/AREImporter.cpp @@ -340,13 +340,14 @@ Map* AREImporter::GetMap(const char *ResRef, bool day_or_night) } // Small map for MapControl - ResourceHolder sm(TmpResRef); // small map is *optional*! + ResourceHolder sm(TmpResRef); if (Script[0]) { - map->Scripts[0] = new GameScript( Script, map ); - } else { - map->Scripts[0] = NULL; + //for some reason the area's script is run from the last slot + //at least one area script depends on this, if you need something + //more customisable, add a game flag + map->Scripts[MAX_SCRIPTS-1] = new GameScript( Script, map ); } if (day_or_night) { @@ -450,6 +451,11 @@ Map* AREImporter::GetMap(const char *ResRef, bool day_or_night) str->ReadWord( &LaunchY ); str->ReadResRef( KeyResRef ); str->ReadResRef( Script ); + //if the Script field is empty, the area name will be copied into it on first load + //this works only in the iwd branch of the games + if (!Script[0] && core->HasFeature(GF_FORCE_AREA_SCRIPT) ) { + memcpy(Script, ResRef, sizeof(ieResRef) ); + } str->ReadWord( &PosX); str->ReadWord( &PosY); //maybe we have to store this diff --git a/project/jni/application/gemrb/src/plugins/AREImporter/AREImporter.h b/project/jni/application/gemrb/gemrb/plugins/AREImporter/AREImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/AREImporter/AREImporter.h rename to project/jni/application/gemrb/gemrb/plugins/AREImporter/AREImporter.h diff --git a/project/jni/application/gemrb/src/plugins/AREImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/AREImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/AREImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/AREImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/AREImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/AREImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/AREImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/AREImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/BAMImporter/BAMImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/BAMImporter/BAMImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BAMImporter/BAMImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/BAMImporter/BAMImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/BAMImporter/BAMImporter.h b/project/jni/application/gemrb/gemrb/plugins/BAMImporter/BAMImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/BAMImporter/BAMImporter.h rename to project/jni/application/gemrb/gemrb/plugins/BAMImporter/BAMImporter.h diff --git a/project/jni/application/gemrb/src/plugins/BAMImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/BAMImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/BAMImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/BAMImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/BAMImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/BAMImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/BAMImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/BAMImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/BIFImporter/BIFImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/BIFImporter/BIFImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIFImporter/BIFImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIFImporter/BIFImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/BIFImporter/BIFImporter.h b/project/jni/application/gemrb/gemrb/plugins/BIFImporter/BIFImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIFImporter/BIFImporter.h rename to project/jni/application/gemrb/gemrb/plugins/BIFImporter/BIFImporter.h diff --git a/project/jni/application/gemrb/src/plugins/BIFImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/BIFImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIFImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/BIFImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/BIFImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/BIFImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIFImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/BIFImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/BIKPlayer.cpp b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/BIKPlayer.cpp similarity index 94% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/BIKPlayer.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/BIKPlayer.cpp index 65092ab87..aa5228e02 100644 --- a/project/jni/application/gemrb/src/plugins/BIKPlayer/BIKPlayer.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/BIKPlayer.cpp @@ -59,12 +59,8 @@ static const int ff_wma_critical_freqs[25] = { 24500, }; -static uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; - BIKPlayer::BIKPlayer(void) { - int i; - video = core->GetVideoDriver(); inbuff = NULL; maxRow = 0; @@ -73,12 +69,6 @@ BIKPlayer::BIKPlayer(void) //force initialisation of static tables memset(bink_trees, 0, sizeof(bink_trees)); memset(table, 0, sizeof(table)); - - for(i=0;i<256;i++) ff_cropTbl[i + MAX_NEG_CROP] = i; - for(i=0;iSeek(frame.pos, GEM_STREAM_START); ieDword audframesize; str->ReadDword(&audframesize); @@ -482,7 +470,7 @@ int BIKPlayer::sound_init(bool need_init) return ret; } -void BIKPlayer::ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){ +void BIKPlayer::ff_init_scantable(ScanTable *st, const uint8_t *src_scantable){ int i,j; int end; @@ -490,7 +478,7 @@ void BIKPlayer::ff_init_scantable(uint8_t *permutation, ScanTable *st, const uin for(i=0; i<64; i++){ j = src_scantable[i]; - st->permutated[i] = permutation[j]; + st->permutated[i] = j; } end=-1; @@ -524,14 +512,7 @@ int BIKPlayer::video_init(int w, int h) return 1; } - //pixel format is PIX_FMT_YUV420P - //idct permutation is used in various optimisations, - //we go with the simplest (no permutation) - for(i=0;i<64;i++) { - c_idct_permutation[i]=i; - } - - ff_init_scantable(c_idct_permutation, &c_scantable, bink_scan); + ff_init_scantable(&c_scantable, bink_scan); bw = (header.width + 7) >> 3; bh = (header.height + 7) >> 3; @@ -1156,7 +1137,8 @@ int BIKPlayer::read_colors(Bundle *b) int BIKPlayer::read_dcs(Bundle *b, int start_bits, int has_sign) { int i, j, len, len2, bsize, v, v2; - int16_t *dst = (int16_t*)b->cur_dec; + SET_INT_TYPE *dst = (SET_INT_TYPE*)b->cur_dec; + //int16_t *dst = (int16_t*)b->cur_dec; CHECK_READ_VAL(v_gb, b, len); if (has_sign) { @@ -1166,7 +1148,8 @@ int BIKPlayer::read_dcs(Bundle *b, int start_bits, int has_sign) } else { v = v_gb.get_bits(start_bits); } - *dst++ = v; + SET_INT_VALUE(dst, v); + //*dst++ = v; len--; for (i = 0; i < len; i += 8) { len2 = FFMIN(len - i, 8); @@ -1178,14 +1161,16 @@ int BIKPlayer::read_dcs(Bundle *b, int start_bits, int has_sign) v2 = -v2; } v += v2; - *dst++ = v; + SET_INT_VALUE(dst, v); + //*dst++ = v; if (v < -32768 || v > 32767) { return -1; } } } else { for (j = 0; j < len2; j++) { - *dst++ = v; + SET_INT_VALUE(dst, v); + //*dst++ = v; } } } @@ -1204,8 +1189,9 @@ inline int BIKPlayer::get_value(int bundle) if (bundle == BINK_SRC_X_OFF || bundle == BINK_SRC_Y_OFF) { return (int8_t)*c_bundle[bundle].cur_ptr++; } - ret = *(int16_t*)c_bundle[bundle].cur_ptr; - c_bundle[bundle].cur_ptr += 2; + GET_INT_VALUE(ret, c_bundle[bundle].cur_ptr); + //ret = *(int16_t*)c_bundle[bundle].cur_ptr; + //c_bundle[bundle].cur_ptr += 2; return ret; } @@ -1234,50 +1220,47 @@ static void get_pixels(DCTELEM *block, const uint8_t *pixels, int line_size) } } -static void put_pixels_clamped(const DCTELEM *block, uint8_t *pixels, int line_size) +static void put_pixels_nonclamped(const DCTELEM *block, uint8_t *pixels, int line_size) { - int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - /* read the pixels */ - for(i=0;i<8;i++) { - pixels[0] = cm[block[0]]; - pixels[1] = cm[block[1]]; - pixels[2] = cm[block[2]]; - pixels[3] = cm[block[3]]; - pixels[4] = cm[block[4]]; - pixels[5] = cm[block[5]]; - pixels[6] = cm[block[6]]; - pixels[7] = cm[block[7]]; - pixels += line_size; - block += 8; - } + int i; + /* read the pixels */ + for(i=0;i<8;i++) { + pixels[0] = block[0]; + pixels[1] = block[1]; + pixels[2] = block[2]; + pixels[3] = block[3]; + pixels[4] = block[4]; + pixels[5] = block[5]; + pixels[6] = block[6]; + pixels[7] = block[7]; + pixels += line_size; + block += 8; + } } -static void add_pixels_clamped(const DCTELEM *block, uint8_t *pixels, int line_size) +static void add_pixels_nonclamped(const DCTELEM *block, uint8_t *pixels, int line_size) { - int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + int i; - /* read the pixels */ - for(i=0;i<8;i++) { - pixels[0] = cm[pixels[0] + block[0]]; - pixels[1] = cm[pixels[1] + block[1]]; - pixels[2] = cm[pixels[2] + block[2]]; - pixels[3] = cm[pixels[3] + block[3]]; - pixels[4] = cm[pixels[4] + block[4]]; - pixels[5] = cm[pixels[5] + block[5]]; - pixels[6] = cm[pixels[6] + block[6]]; - pixels[7] = cm[pixels[7] + block[7]]; - pixels += line_size; - block += 8; - } + /* read the pixels */ + for(i=0;i<8;i++) { + pixels[0] += block[0]; + pixels[1] += block[1]; + pixels[2] += block[2]; + pixels[3] += block[3]; + pixels[4] += block[4]; + pixels[5] += block[5]; + pixels[6] += block[6]; + pixels[7] += block[7]; + pixels += line_size; + block += 8; + } } static inline void copy_block(DCTELEM block[64], const uint8_t *src, uint8_t *dst, int stride) { get_pixels(block, src, stride); - put_pixels_clamped(block, dst, stride); + put_pixels_nonclamped(block, dst, stride); } #define clear_block(block) memset( (block), 0, sizeof(DCTELEM)*64); @@ -1362,12 +1345,13 @@ void bink_idct(DCTELEM *block) static void idct_put(uint8_t *dest, int line_size, DCTELEM *block) { bink_idct(block); - put_pixels_clamped(block, dest, line_size); + put_pixels_nonclamped(block, dest, line_size); } + static void idct_add(uint8_t *dest, int line_size, DCTELEM *block) { bink_idct(block); - add_pixels_clamped(block, dest, line_size); + add_pixels_nonclamped(block, dest, line_size); } int BIKPlayer::DecodeVideoFrame(void *data, int data_size) @@ -1433,7 +1417,7 @@ int BIKPlayer::DecodeVideoFrame(void *data, int data_size) prev = c_last.data[plane] + 8*by*stride; for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) { blk = get_value(BINK_SRC_BLOCK_TYPES); - if ((by & 1) && blk == 1) { + if ((by & 1) && (blk == SCALED_BLOCK) ) { bx++; dst += 8; prev += 8; @@ -1552,7 +1536,7 @@ int BIKPlayer::DecodeVideoFrame(void *data, int data_size) clear_block(block); v = v_gb.get_bits(7); read_residue(block, v); - add_pixels_clamped(block, dst, stride); + add_pixels_nonclamped(block, dst, stride); break; case INTRA_BLOCK: clear_block(block); diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/BIKPlayer.h b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/BIKPlayer.h similarity index 92% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/BIKPlayer.h rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/BIKPlayer.h index a59e32397..628d282e8 100644 --- a/project/jni/application/gemrb/src/plugins/BIKPlayer/BIKPlayer.h +++ b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/BIKPlayer.h @@ -41,6 +41,31 @@ #define MAX_CHANNELS 2 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11) +#if defined(__arm__) +#define SET_INT_TYPE uint8_t +#define SET_INT_VALUE(ptr, value)\ + *(ptr) = (value) && 0xff; \ + (ptr)++; \ + *(ptr) = ((value) >> 8) && 0xff; \ + (ptr)++; +#else +#define SET_INT_TYPE int16_t +#define SET_INT_VALUE(ptr, value)\ + *(ptr)++ = (value); +#endif + +#if defined(__arm__) +#define GET_INT_VALUE(value, ptr)\ + (value) = *(ptr); \ + (ptr)++; \ + (value) |= (*(ptr)) << 8; \ + (ptr)++; +#else +#define GET_INT_VALUE(value, ptr)\ + (value) = *(int16_t*)(ptr); \ + (ptr) += 2; +#endif + enum BinkAudFlags { BINK_AUD_16BITS = 0x4000, ///< prefer 16-bit output BINK_AUD_STEREO = 0x2000, @@ -175,7 +200,6 @@ private: int outputwidth, outputheight; unsigned int video_skippedframes; //bink specific - uint8_t c_idct_permutation[64]; ScanTable c_scantable; Bundle c_bundle[BINK_NB_SRC]; ///< bundles for decoding all data types Tree c_col_high[16]; ///< trees for decoding high nibble in "colours" data type @@ -203,7 +227,7 @@ private: void queueBuffer(int stream, unsigned short bits, int channels, short* memory, int size, int samplerate); int sound_init(bool need_init); - void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable); + void ff_init_scantable(ScanTable *st, const uint8_t *src_scantable); int video_init(int w, int h); void av_set_pts_info(AVRational &time_base, unsigned int pts_num, unsigned int pts_den); int ReadHeader(); diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/GetBitContext.cpp b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/GetBitContext.cpp similarity index 96% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/GetBitContext.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/GetBitContext.cpp index eaaca2def..5ef416a47 100644 --- a/project/jni/application/gemrb/src/plugins/BIKPlayer/GetBitContext.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/GetBitContext.cpp @@ -175,22 +175,6 @@ int VLC::alloc_table(int size) return index; } -#define GET_DATA(v, table, i, wrap, size) \ -{\ - const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ - switch(size) {\ - case 1:\ - v = *(const uint8_t *)ptr;\ - break;\ - case 2:\ - v = *(const uint16_t *)ptr;\ - break;\ - default:\ - v = *(const uint32_t *)ptr;\ - break;\ - }\ -} - int VLC::build_table(int table_nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, diff --git a/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/GetBitContext.h b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/GetBitContext.h new file mode 100644 index 000000000..d056f37f3 --- /dev/null +++ b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/GetBitContext.h @@ -0,0 +1,107 @@ +/* GemRB - Infinity Engine Emulator + * Copyright (C) 2009 The GemRB Project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +//code derived from FFMPEG +//using code from get_bits.h, bitstream.c + +#include "common.h" + +#define INIT_VLC_LE 2 +#define INIT_VLC_USE_NEW_STATIC 4 + +class VLC +{ +public: + int bits; + int16_t (*table)[2]; ///< code, bits + int table_size, table_allocated; +public: + int init_vlc(int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + int flags); +private: + int alloc_table(int size); + int build_table(int table_nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + uint32_t code_prefix, int n_prefix, int flags); + +}; + +#if defined(__arm__) +#define GET_DATA(v, table, i, wrap, size) \ +{\ + const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ + v = 0;\ + switch(size) {\ + default:\ + v |= *((const uint8_t *)ptr+3) << 24;\ + v |= *((const uint8_t *)ptr+2) << 16;\ + case 2:\ + v |= *((const uint8_t *)ptr+1) << 8;\ + case 1:\ + v |= *(const uint8_t *)ptr;\ + }\ +} +#else +#define GET_DATA(v, table, i, wrap, size) \ +{\ + const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ + switch(size) {\ + case 1:\ + v = *(const uint8_t *)ptr;\ + break;\ + case 2:\ + v = *(const uint16_t *)ptr;\ + break;\ + default:\ + v = *(const uint32_t *)ptr;\ + break;\ + }\ +} +#endif + +#define AV_RL32(x) \ + ((((const uint8_t*)(x))[3] << 24) | \ + (((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) + +class GetBitContext +{ +public: + const uint8_t *buffer, *buffer_end; + int index; + int size_in_bits; +public: + void debug(const char *prefix); + float get_float(); + void skip_bits(int x) { index+=x; } + int get_bits_count() { return index; } + void get_bits_align32(); + unsigned int get_bits(int x); + unsigned int peek_bits(int x); + unsigned int get_bits_long(int n); + void init_get_bits(const uint8_t *b, int bit_size); + void read_tree(Tree *tree); +private: + void merge( uint8_t *dst, uint8_t *src, int size); +}; diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/binkdata.h b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/binkdata.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/binkdata.h rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/binkdata.h diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/common.h b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/common.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/common.h rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/common.h diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/dct.cpp b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/dct.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/dct.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/dct.cpp diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/dsputil.h b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/dsputil.h similarity index 99% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/dsputil.h rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/dsputil.h index 7e21dc6cb..84161fad9 100644 --- a/project/jni/application/gemrb/src/plugins/BIKPlayer/dsputil.h +++ b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/dsputil.h @@ -37,9 +37,6 @@ typedef short DCTELEM; typedef int DWTELEM; typedef short IDWTELEM; -/* pixel operations */ -#define MAX_NEG_CROP 1024 - /** * Scantable. */ diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/fft.cpp b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/fft.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/fft.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/fft.cpp diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/mem.cpp b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/mem.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/mem.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/mem.cpp diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/rational.cpp b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/rational.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/rational.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/rational.cpp diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/rational.h b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/rational.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/rational.h rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/rational.h diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/rdft.cpp b/project/jni/application/gemrb/gemrb/plugins/BIKPlayer/rdft.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BIKPlayer/rdft.cpp rename to project/jni/application/gemrb/gemrb/plugins/BIKPlayer/rdft.cpp diff --git a/project/jni/application/gemrb/src/plugins/BMPImporter/BMPImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/BMPImporter/BMPImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPImporter/BMPImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/BMPImporter/BMPImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/BMPImporter/BMPImporter.h b/project/jni/application/gemrb/gemrb/plugins/BMPImporter/BMPImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPImporter/BMPImporter.h rename to project/jni/application/gemrb/gemrb/plugins/BMPImporter/BMPImporter.h diff --git a/project/jni/application/gemrb/src/plugins/BMPImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/BMPImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/BMPImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/BMPImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/BMPImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/BMPImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/BMPWriter/BMPWriter.cpp b/project/jni/application/gemrb/gemrb/plugins/BMPWriter/BMPWriter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPWriter/BMPWriter.cpp rename to project/jni/application/gemrb/gemrb/plugins/BMPWriter/BMPWriter.cpp diff --git a/project/jni/application/gemrb/src/plugins/BMPWriter/BMPWriter.h b/project/jni/application/gemrb/gemrb/plugins/BMPWriter/BMPWriter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPWriter/BMPWriter.h rename to project/jni/application/gemrb/gemrb/plugins/BMPWriter/BMPWriter.h diff --git a/project/jni/application/gemrb/src/plugins/BMPWriter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/BMPWriter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPWriter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/BMPWriter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/BMPWriter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/BMPWriter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/BMPWriter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/BMPWriter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/CHUImporter/CHUImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/CHUImporter/CHUImporter.cpp similarity index 93% rename from project/jni/application/gemrb/src/plugins/CHUImporter/CHUImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/CHUImporter/CHUImporter.cpp index 5f965b7cf..4d9609d04 100644 --- a/project/jni/application/gemrb/src/plugins/CHUImporter/CHUImporter.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/CHUImporter/CHUImporter.cpp @@ -185,7 +185,7 @@ Window* CHUImporter::GetWindow(unsigned int wid) if (!bam ) { printMessage( "CHUImporter","Cannot Load Button Images, skipping control\n",LIGHT_RED ); /* IceWind Dale 2 has fake BAM ResRefs for some Buttons, - this will handle bad ResRefs */ + this will handle bad ResRefs */ win->AddControl( btn ); break; } @@ -230,7 +230,7 @@ Window* CHUImporter::GetWindow(unsigned int wid) str->ReadWord( &KnobYPos ); str->ReadWord( &CapXPos ); str->ReadWord( &CapYPos ); - Progressbar* pbar = new Progressbar(KnobStepsCount, true ); + Progressbar* pbar = new Progressbar(KnobStepsCount, true ); pbar->ControlID = ControlID; pbar->XPos = XPos; pbar->YPos = YPos; @@ -249,7 +249,7 @@ Window* CHUImporter::GetWindow(unsigned int wid) ResourceHolder mos(MOSFile2); img2 = mos->GetSprite2D(); } - + pbar->SetImage( img, img2 ); if( KnobStepsCount ) { /* getting the bam */ @@ -302,7 +302,7 @@ Window* CHUImporter::GetWindow(unsigned int wid) sldr->SetImage( IE_GUI_SLIDER_GRABBEDKNOB, img ); } else { - sldr->SetState(IE_GUI_SLIDER_BACKGROUND); + sldr->SetState(IE_GUI_SLIDER_BACKGROUND); } win->AddControl( sldr ); } @@ -314,30 +314,41 @@ Window* CHUImporter::GetWindow(unsigned int wid) ieResRef BGMos; ieResRef FontResRef, CursorResRef; ieWord maxInput; - ieWord CurCycle, CurFrame; - ieWord PosX, PosY; + ieWord CurCycle, CurFrame; + ieWord PosX, PosY; + ieWord Pos2X, Pos2Y; + ieVariable Initial; str->ReadResRef( BGMos ); + //These are two more MOS resrefs, probably unused str->Seek( 16, GEM_CURRENT_POS ); str->ReadResRef( CursorResRef ); - str->ReadWord( &CurCycle ); - str->ReadWord( &CurFrame ); - str->ReadWord( &PosX ); - str->ReadWord( &PosY ); - str->Seek( 4, GEM_CURRENT_POS ); + str->ReadWord( &CurCycle ); + str->ReadWord( &CurFrame ); + str->ReadWord( &PosX ); + str->ReadWord( &PosY ); + //FIXME: I still don't know what to do with this point + //Contrary to forum posts, it is definitely not a scrollbar ID + str->ReadWord( &Pos2X ); + str->ReadWord( &Pos2Y ); str->ReadResRef( FontResRef ); - str->Seek( 34, GEM_CURRENT_POS ); + //this field is still unknown or unused + str->Seek( 2, GEM_CURRENT_POS ); + //This is really a text field, but apparently the original engine + //always writes it over, and never uses it + str->Read( Initial, 32 ); + Initial[32]=0; str->ReadWord( &maxInput ); Font* fnt = core->GetFont( FontResRef ); - + AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( CursorResRef, IE_BAM_CLASS_ID, IE_NORMAL ); Sprite2D *cursor = NULL; - if (bam) { + if (bam) { cursor = bam->GetFrame( CurCycle, CurFrame ); - } + } ResourceHolder mos(BGMos); Sprite2D *img = NULL; @@ -355,6 +366,8 @@ Window* CHUImporter::GetWindow(unsigned int wid) te->SetFont( fnt ); te->SetCursor( cursor ); te->SetBackGround( img ); + //The original engine always seems to ignore this textfield + //te->SetText (Initial ); win->AddControl( te ); } break; diff --git a/project/jni/application/gemrb/src/plugins/CHUImporter/CHUImporter.h b/project/jni/application/gemrb/gemrb/plugins/CHUImporter/CHUImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/CHUImporter/CHUImporter.h rename to project/jni/application/gemrb/gemrb/plugins/CHUImporter/CHUImporter.h diff --git a/project/jni/application/gemrb/src/plugins/CHUImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/CHUImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/CHUImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/CHUImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/CHUImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/CHUImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/CHUImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/CHUImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/CREImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/CREImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/CREImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/CREImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/CREImporter/CREImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/CREImporter/CREImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/CREImporter/CREImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/CREImporter/CREImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/CREImporter/CREImporter.h b/project/jni/application/gemrb/gemrb/plugins/CREImporter/CREImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/CREImporter/CREImporter.h rename to project/jni/application/gemrb/gemrb/plugins/CREImporter/CREImporter.h diff --git a/project/jni/application/gemrb/src/plugins/CREImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/CREImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/CREImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/CREImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/DLGImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/DLGImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/DLGImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/DLGImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/DLGImporter/DLGImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/DLGImporter/DLGImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/DLGImporter/DLGImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/DLGImporter/DLGImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/DLGImporter/DLGImporter.h b/project/jni/application/gemrb/gemrb/plugins/DLGImporter/DLGImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/DLGImporter/DLGImporter.h rename to project/jni/application/gemrb/gemrb/plugins/DLGImporter/DLGImporter.h diff --git a/project/jni/application/gemrb/src/plugins/DLGImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/DLGImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/DLGImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/DLGImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/DirectoryImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/DirectoryImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/DirectoryImporter/DirectoryImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/DirectoryImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/DirectoryImporter/DirectoryImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/DirectoryImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/DirectoryImporter/DirectoryImporter.h b/project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/DirectoryImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/DirectoryImporter/DirectoryImporter.h rename to project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/DirectoryImporter.h diff --git a/project/jni/application/gemrb/src/plugins/DirectoryImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/DirectoryImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/DirectoryImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/EFFImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/EFFImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/EFFImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/EFFImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/EFFImporter/EFFImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/EFFImporter/EFFImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/EFFImporter/EFFImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/EFFImporter/EFFImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/EFFImporter/EFFImporter.h b/project/jni/application/gemrb/gemrb/plugins/EFFImporter/EFFImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/EFFImporter/EFFImporter.h rename to project/jni/application/gemrb/gemrb/plugins/EFFImporter/EFFImporter.h diff --git a/project/jni/application/gemrb/src/plugins/EFFImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/EFFImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/EFFImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/EFFImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/FXOpcodes/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/FXOpcodes/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/FXOpcodes/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/FXOpcodes/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/FXOpcodes/FXOpcodes.cpp b/project/jni/application/gemrb/gemrb/plugins/FXOpcodes/FXOpcodes.cpp similarity index 97% rename from project/jni/application/gemrb/src/plugins/FXOpcodes/FXOpcodes.cpp rename to project/jni/application/gemrb/gemrb/plugins/FXOpcodes/FXOpcodes.cpp index 20376774d..867cde181 100644 --- a/project/jni/application/gemrb/src/plugins/FXOpcodes/FXOpcodes.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/FXOpcodes/FXOpcodes.cpp @@ -35,12 +35,14 @@ #include "TileMap.h" //needs for knock! #include "damages.h" #include "GameScript/GSUtils.h" //needs for MoveBetweenAreasCore +#include "GameScript/Matching.h" //needs for GetAllObjects #include "GUI/GameControl.h" #include "Scriptable/Actor.h" #include "PolymorphCache.h" // fx_polymorph #include "Scriptable/PCStatStruct.h" //fx_polymorph (action definitions) //FIXME: find a way to handle portrait icons better +#define PI_RIGID 2 #define PI_CONFUSED 3 #define PI_BERSERK 4 #define PI_POISONED 6 @@ -411,6 +413,7 @@ int fx_golem_stoneskin_modifier (Scriptable* Owner, Actor* target, Effect* fx);/ int fx_avatar_removal_modifier (Scriptable* Owner, Actor* target, Effect* fx);//13b int fx_magical_rest (Scriptable* Owner, Actor* target, Effect* fx);//13c //int fx_improved_haste_state (Scriptable* Owner, Actor* target, Effect* fx);//13d same as haste +int fx_change_weather (Scriptable* Owner, Actor* target, Effect* fx);//13e ChangeWeather int fx_unknown (Scriptable* Owner, Actor* target, Effect* fx);//??? @@ -465,6 +468,7 @@ static EffectRef effectnames[] = { { "CastSpellOnCondition", fx_cast_spell_on_condition, -1 }, { "ChangeBardSong", fx_change_bardsong, -1 }, { "ChangeName", fx_change_name, -1 }, + { "ChangeWeather", fx_change_weather, -1 }, { "ChantBadNonCumulative", fx_set_chantbad_state, -1 }, { "ChantNonCumulative", fx_set_chant_state, -1 }, { "ChaosShieldModifier", fx_chaos_shield_modifier, -1 }, @@ -1233,7 +1237,7 @@ int fx_death (Scriptable* Owner, Actor* target, Effect* fx) ieDword damagetype = 0; switch (fx->Parameter2) { case 1: - BASE_STATE_SET(STATE_D4); //not sure, should be charred + BASE_STATE_SET(STATE_FLAME); //not sure, should be charred damagetype = DAMAGE_FIRE; break; case 2: @@ -1269,6 +1273,9 @@ int fx_death (Scriptable* Owner, Actor* target, Effect* fx) default: damagetype = DAMAGE_ACID; } + //these two bits are turned off on death + BASE_STATE_CURE(STATE_FROZEN|STATE_PETRIFIED); + target->Damage(0, damagetype, Owner); //death has damage type too target->Die(Owner); @@ -1414,7 +1421,12 @@ int fx_maximum_hp_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_maximum_hp_modifier (%2d): Mod: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); - if (STATE_GET( STATE_DEAD|STATE_PETRIFIED|STATE_FROZEN) ) { + //state_exploding is different in PST, probably not needed anyway + if (STATE_GET(STATE_DEAD|STATE_PETRIFIED|STATE_FROZEN|STATE_ACID|STATE_FLAME) ) { + return FX_NOT_APPLIED; + } + + if (BASE_GET(IE_HITPOINTS)<=0 ) { return FX_NOT_APPLIED; } @@ -1548,6 +1560,7 @@ int fx_morale_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_morale_modifier (%2d): Mod: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); + //FIXME: in bg2 this is hacked to set param1=10, param2=1, we might need some flag for this STAT_MOD( IE_MORALE ); return FX_APPLIED; } @@ -1576,10 +1589,8 @@ int fx_set_panic_state (Scriptable* /*Owner*/, Actor* target, Effect* fx) int fx_set_poisoned_state (Scriptable* Owner, Actor* target, Effect* fx) { if (0) printf( "fx_set_poisoned_state (%2d): Damage: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); - //apparently this bit isn't set, but then why is it here - //this requires a little research STATE_SET( STATE_POISONED ); - //also this effect is executed every update + ieDword damage; int tmp = fx->Parameter1; @@ -1716,8 +1727,11 @@ int fx_magic_damage_resistance_modifier (Scriptable* /*Owner*/, Actor* target, E int fx_cure_dead_state (Scriptable* Owner, Actor* target, Effect* fx) { if (0) printf( "fx_cure_dead_state (%2d): Mod: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); - Point p(fx->PosX, fx->PosY); - Resurrect(Owner, target, fx, p); + //call this only if the target is dead, otherwise some variables can get wrong + if (STATE_GET(STATE_DEAD) ) { + Point p(fx->PosX, fx->PosY); + Resurrect(Owner, target, fx, p); + } return FX_NOT_APPLIED; } @@ -2557,6 +2571,12 @@ int fx_set_diseased_state (Scriptable* Owner, Actor* target, Effect* fx) break; case RPD_SLOW: //slow break; + case RPD_MOLD: //mold touch (how) + EXTSTATE_SET(EXTSTATE_MOLD); + damage = 1; + break; + case RPD_MOLD2: + break; default: damage = 1; break; @@ -2885,6 +2905,7 @@ int fx_protection_spelllevel (Scriptable* /*Owner*/, Actor* target, Effect* fx) int fx_change_name (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_change_name_modifier (%2d): StrRef: %d\n", fx->Opcode, fx->Parameter1 ); + //this also changes the base stat target->SetName(fx->Parameter1, 0); return FX_NOT_APPLIED; } @@ -2893,8 +2914,9 @@ int fx_change_name (Scriptable* /*Owner*/, Actor* target, Effect* fx) int fx_experience_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_experience_modifier (%2d): Mod: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); - //i believe this has mode too - target->AddExperience (fx->Parameter1); + //FIXME: this has mode too + //target->AddExperience (fx->Parameter1); + STAT_MOD( IE_XP ); return FX_NOT_APPLIED; } @@ -3116,10 +3138,7 @@ int fx_mirror_image (Scriptable* Owner, Actor* target, Effect* fx) else { // the original uses only IE_LEVEL, but that can be awefully bad in // the case of dual- and multiclasses - unsigned int level = target->GetMageLevel(); - if (!level) level = target->GetSorcererLevel(); - if (!level) level = target->GetBardLevel(); - if (!level) level = target->GetStat(IE_LEVEL); + unsigned int level = target->GetCasterLevel(IE_SPL_WIZARD); // 2-8 mirror images images = level/3 + 2; if (images > 8) images = 8; @@ -3365,10 +3384,10 @@ int fx_monster_summoning (Scriptable* Owner, Actor* target, Effect* fx) core->GetResRefFrom2DA(monster_summoning_2da[fx->Parameter2], monster, hit, areahit); if (!hit[0]) { - strnuprcpy(hit,fx->Resource2,8); + strnuprcpy(hit, fx->Resource2, 8); } if (!areahit[0]) { - strnuprcpy(areahit,fx->Resource3,8); + strnuprcpy(areahit, fx->Resource3, 8); } //the monster should appear near the effect position @@ -3412,6 +3431,8 @@ int fx_set_confused_state (Scriptable* /*Owner*/, Actor* target, Effect* fx) } //NOTE: iwd2 is also unable to display the portrait icon //for permanent confusion + //the portrait icon cannot be made common because rigid thinking uses a different icon + //in bg2/how if (enhanced_effects) { target->AddPortraitIcon(PI_CONFUSED); } @@ -3874,7 +3895,7 @@ int fx_cast_spell (Scriptable* Owner, Actor* target, Effect* fx) //cast spell on target Owner->CastSpell(fx->Resource, target, false); //actually finish casting (if this is not good enough, use an action???) - Owner->CastSpellEnd(fx->Resource); + Owner->CastSpellEnd(); } return FX_NOT_APPLIED; } @@ -3886,7 +3907,8 @@ int fx_learn_spell (Scriptable* /*Owner*/, Actor* target, Effect* fx) //parameter1 is unused, gemrb lets you to make it not give XP //probably we should also let this via a game flag if we want //full compatibility with bg1 - target->LearnSpell(fx->Resource, fx->Parameter2^LS_ADDXP); + //parameter2 is used in bg1 and pst to specify the spell type; bg2 and iwd2 figure it out from the resource + target->LearnSpell(fx->Resource, fx->Parameter1^LS_ADDXP); return FX_NOT_APPLIED; } // 0x94 Spell:CastSpellPoint @@ -3895,7 +3917,7 @@ int fx_cast_spell_point (Scriptable* Owner, Actor* target, Effect* fx) if (0) printf( "fx_cast_spell_point (%2d): Resource:%s Mode: %d\n", fx->Opcode, fx->Resource, fx->Parameter2 ); Owner->CastSpellPoint(fx->Resource, target->Pos, false); //actually finish casting (if this is not good enough, use an action???) - Owner->CastSpellPointEnd(fx->Resource); + Owner->CastSpellPointEnd(); return FX_NOT_APPLIED; } @@ -3931,7 +3953,7 @@ int fx_find_traps (Scriptable* /*Owner*/, Actor* target, Effect* fx) break; //find traps case 3: //detect secret doors - skill = target->LuckyRoll(1,100,0); + skill = target->LuckyRoll(1, 100, 0, 0); detecttraps = false; break; case 2: @@ -4498,15 +4520,24 @@ int fx_attackspeed_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) } // 0xbf CastingLevelModifier +// gemrb extension: if the resource key is set, apply param1 as a percentual modifier int fx_castinglevel_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_castinglevel_modifier (%2d) Value:%d Type:%d", fx->Opcode, fx->Parameter1, fx->Parameter2 ); switch (fx->Parameter2) { case 0: - STAT_SET( IE_CASTINGLEVELBONUSMAGE, fx->Parameter1 ); + if (fx->Resource[0]) { + STAT_MUL( IE_CASTINGLEVELBONUSMAGE, fx->Parameter1 ); + } else { + STAT_SET( IE_CASTINGLEVELBONUSMAGE, fx->Parameter1 ); + } break; case 1: - STAT_SET( IE_CASTINGLEVELBONUSCLERIC, fx->Parameter1 ); + if (fx->Resource[0]) { + STAT_MUL( IE_CASTINGLEVELBONUSCLERIC, fx->Parameter1 ); + } else { + STAT_SET( IE_CASTINGLEVELBONUSCLERIC, fx->Parameter1 ); + } break; default: return FX_NOT_APPLIED; @@ -4534,9 +4565,25 @@ int fx_find_familiar (Scriptable* Owner, Actor* target, Effect* fx) } if (!target->GetCurrentArea()) { + //this will delay casting until we get an area return FX_APPLIED; } + Game *game = core->GetGame(); + //FIXME: the familiar block field is not saved in the game and not set when the + //familiar is itemized, so a game reload will clear it (see how this is done in original) + if (game->familiarBlock) { + displaymsg->DisplayConstantStringName(STR_FAMBLOCK, 0xff0000, target); + return FX_NOT_APPLIED; + } + + //The protagonist is ALWAYS in the first slot + if (game->GetPC(0, false)!=target) { + displaymsg->DisplayConstantStringName(STR_FAMPROTAGONIST, 0xff0000, target); + return FX_NOT_APPLIED; + } + + if (fx->Parameter2!=FAMILIAR_RESOURCE) { ieDword alignment; @@ -4655,12 +4702,10 @@ int fx_familiar_marker (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_familiar_marker (%2d)\n", fx->Opcode ); if (! (STAT_GET(IE_STATE_ID)&STATE_NOSAVE)) { - //TODO: where to disable familiar? - //core->GetGame()->WeatherBits|=1; + core->GetGame()->familiarBlock=true; return FX_APPLIED; } - //TODO: enable familiar? - //core->GetGame()->WeatherBits&=~1; + core->GetGame()->familiarBlock=false; return FX_NOT_APPLIED; } @@ -4843,7 +4888,7 @@ int fx_power_word_stun (Scriptable* Owner, Actor* target, Effect* fx) //0xd3 State:Imprisonment (avatar removal plus portrait icon) int fx_imprisonment (Scriptable* /*Owner*/, Actor* target, Effect* fx) { - if (0) printf( "fx_inprisonment (%2d)\n", fx->Opcode ); + if (0) printf( "fx_imprisonment (%2d)\n", fx->Opcode ); target->SetMCFlag(MC_HIDDEN, BM_OR); target->AddPortraitIcon(PI_PRISON); return FX_APPLIED; @@ -4865,17 +4910,42 @@ int fx_freedom (Scriptable* /*Owner*/, Actor* target, Effect* fx) int fx_maze (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_maze (%2d)\n", fx->Opcode ); + if (!fx->Parameter2 && fx->FirstApply) { + //get the maze dice number (column 3) + int stat = target->GetSafeStat(IE_INT); + int size = core->GetIntelligenceBonus(3, stat); + int dice = core->GetIntelligenceBonus(4, stat); + fx->Duration = core->GetGame()->GameTime+target->LuckyRoll(dice, size, 0, 0)*100; + } target->SetMCFlag(MC_HIDDEN, BM_OR); target->AddPortraitIcon(PI_MAZE); return FX_APPLIED; } //0xd6 CastFromList -int fx_select_spell (Scriptable* /*Owner*/, Actor* /*target*/, Effect* fx) +//GemRB extension: if fx->Parameter1 is set, it is the bitfield of spell types (could be priest spells) +int fx_select_spell (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_select_spell (%2d) %d\n", fx->Opcode, fx->Parameter2 ); - //if parameter2==0 -> cast spells from 2da (all spells listed in 2da) - //if parameter2==1 -> cast spells from book (all known spells, no need of memorize) + Spellbook *sb = &target->spellbook; + if(fx->Parameter2) { + //all known spells, no need to memorize + if (!fx->Parameter1) { + fx->Parameter1=1<SetCustomSpellInfo(NULL, fx->Source, fx->Parameter1); + } else { + //all spells listed in 2da + ieResRef *data = NULL; + + int count = core->ReadResRefTable(fx->Resource, data); + sb->SetCustomSpellInfo(data, fx->Source, count); + core->FreeResRefTable(data, count); + } + core->GetDictionary()->SetAt("Type",-1); + //this is required, because not all of these opcodes are firing right at casting + core->GetDictionary()->SetAt("ActionLevel", 2); + core->SetEventFlag(EF_ACTION); return FX_NOT_APPLIED; } @@ -5478,6 +5548,15 @@ int fx_cure_confused_state (Scriptable* /*Owner*/, Actor* target, Effect* fx) if (0) printf( "fx_cure_confused_state (%2d): Mod: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); BASE_STATE_CURE( STATE_CONFUSED ); target->fxqueue.RemoveAllEffects(fx_confused_state_ref); + //FIXME:oddly enough, HoW removes the confused icon + //no one removes the rigid thinking icon + //there are also several mods floating around, which change these things inconsistently + //probably the best is to remove them all by default + //New mods can still disable the icon removal by setting param2 + if (!fx->Parameter2) { + target->fxqueue.RemoveAllEffectsWithParam( fx_display_portrait_icon_ref,PI_CONFUSED ); + target->fxqueue.RemoveAllEffectsWithParam( fx_display_portrait_icon_ref,PI_RIGID ); + } return FX_NOT_APPLIED; } @@ -5588,7 +5667,7 @@ int fx_set_area_effect (Scriptable* Owner, Actor* target, Effect* fx) if (Owner->Type==ST_ACTOR) { skill = ((Actor *)Owner)->GetStat(IE_SETTRAPS); - roll = core->Roll(1,100,0); + roll = target->LuckyRoll(1,100,0,LR_NEGATIVE); } else { roll=0; skill=0; @@ -5596,8 +5675,18 @@ int fx_set_area_effect (Scriptable* Owner, Actor* target, Effect* fx) if (roll>skill) { //failure - displaymsg->DisplayConstantStringName(STR_SNAREFAILED, 0xf0f0f0, target); - //TODO check luck and do some damage effect on target + displaymsg->DisplayConstantStringName(STR_SNAREFAILED, 0xf0f0f0, target); + if (target->LuckyRoll(1,100,0)<25) { + ieResRef spl; + + strnuprcpy(spl, fx->Resource, 8); + if (strlen(spl)<8) { + strcat(spl,"F"); + } else { + spl[7]='F'; + } + core->ApplySpell(spl, target, Owner, fx->Power); + } return FX_NOT_APPLIED; } //success @@ -5852,16 +5941,17 @@ int fx_unpause_caster (Scriptable* /*Owner*/, Actor* target, Effect* fx) target->fxqueue.RemoveAllEffects(fx_pause_caster_modifier_ref); return FX_NOT_APPLIED; } -// 0x10f AvatarRemoval -// 0x104 AvatarRemoval (iwd) + +// 0x10f SummonDisable (bg2) int fx_avatar_removal (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_avatar_removal (%2d): Mod: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); - //FIXME: this is a permanent irreversible effect in IWD - //if it is different in bg2, then create another effect - //bg2 calls this SummonDisable - BASE_SET(IE_AVATARREMOVAL, 1); - return FX_NOT_APPLIED; + STAT_SET(IE_SUMMONDISABLE, 1); + STAT_SET(IE_CASTERHOLD, 1); + if (fx->Parameter2==1) { + STAT_SET(IE_AVATARREMOVAL, 1); + } + return FX_APPLIED; } /* note/TODO from Taimon: @@ -5984,13 +6074,20 @@ int fx_teleport_to_target (Scriptable* /*Owner*/, Actor* target, Effect* fx) Map *map = target->GetCurrentArea(); if (map) { - Actor *victim = map->GetActorByGlobalID(target->LastAttacker); - if (victim) { + Object oC; + oC.objectFields[0]=EA_ENEMY; + Targets *tgts = GetAllObjects(map, target, &oC, GA_NO_DEAD); + int rnd = core->Roll(1,tgts->Count(),-1); + Actor *victim = (Actor *) tgts->GetTarget(rnd, ST_ACTOR); + delete tgts; + if (victim && PersonalDistance(victim, target)>20) { target->SetPosition( victim->Pos, true, 0 ); + target->SetColorMod(0xff, RGBModifier::ADD, 0x50, 0xff, 0xff, 0xff, 0); } } return FX_NOT_APPLIED; } + // 0x113 HideInShadowsModifier int fx_hide_in_shadows_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { @@ -5998,6 +6095,7 @@ int fx_hide_in_shadows_modifier (Scriptable* /*Owner*/, Actor* target, Effect* f STAT_MOD( IE_HIDEINSHADOWS ); return FX_APPLIED; } + // 0x114 DetectIllusionsModifier int fx_detect_illusion_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { @@ -6005,6 +6103,7 @@ int fx_detect_illusion_modifier (Scriptable* /*Owner*/, Actor* target, Effect* f STAT_MOD( IE_DETECTILLUSIONS ); return FX_APPLIED; } + // 0x115 SetTrapsModifier int fx_set_traps_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { @@ -6030,11 +6129,12 @@ int fx_renable_button (Scriptable* /*Owner*/, Actor* target, Effect* fx) target->fxqueue.RemoveAllEffectsWithParam( fx_disable_button_ref, fx->Parameter2 ); return FX_NOT_APPLIED; } + // 0x118 ForceSurgeModifier int fx_force_surge_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) { if (0) printf( "fx_force_surge_modifier (%2d): Mod: %d, Type: %d\n", fx->Opcode, fx->Parameter1, fx->Parameter2 ); - STAT_MOD( IE_FORCESURGE ); + STAT_MOD_VAR( IE_FORCESURGE, MOD_ABSOLUTE ); return FX_APPLIED; } @@ -6397,20 +6497,42 @@ int fx_timeless_modifier (Scriptable* /*Owner*/, Actor* target, Effect* fx) } //0x137 GenerateWish -#define WISHCOUNT 25 -static int wishlevels[WISHCOUNT]={10,10,10,10,0,10,0,15,0,0,0,0,0,0,15,0,0, -17,9,17,17,9,9,9,0}; - +//GemRB extension: you can use different tables and not only wisdom stat int fx_generate_wish (Scriptable* Owner, Actor* target, Effect* fx) { ieResRef spl; if (0) printf( "fx_generate_wish (%2d): Mod: %d\n", fx->Opcode, fx->Parameter2 ); - int tmp = core->Roll(1,WISHCOUNT,0); - sprintf(spl,"SPWISH%02d",tmp); - core->ApplySpell(spl, target, Owner, wishlevels[tmp-1]); + if (!fx->Parameter2) { + fx->Parameter2=IE_WIS; + } + int stat = target->GetSafeStat(fx->Parameter2); + if (!fx->Resource[0]) { + memcpy(fx->Resource,"wishcode",8); + } + AutoTable tm(fx->Resource); + if (!tm) { + return FX_NOT_APPLIED; + } + + int max = tm->GetRowCount(); + int tmp = core->Roll(1,max,0); + int i = tmp; + bool pass = true; + while(--i!=tmp && pass) { + if (i<0) { + pass=false; + i=max-1; + } + int min = atoi(tm->QueryField(i, 1)); + int max = atoi(tm->QueryField(i, 2)); + if (stat>=min && stat<=max) break; + } + strnuprcpy(spl, tm->QueryField(i,0), 8); + core->ApplySpell(spl, target, Owner, fx->Power); return FX_NOT_APPLIED; } + //0x138 //see fx_crash, this effect is not fully enabled in original bg2/tob int fx_immunity_sequester (Scriptable* /*Owner*/, Actor* target, Effect* fx) { @@ -6457,6 +6579,22 @@ int fx_magical_rest (Scriptable* /*Owner*/, Actor* target, Effect* fx) } // 0x13d ImprovedHaste (See 0x10 Haste) + +// 0x13e ChangeWeather +// sets the weather to param1, set it to: +// 0 normal weather +// 1 rain +// 2 snow +// 3 fog +int fx_change_weather (Scriptable* /*Owner*/, Actor* /*target*/, Effect* fx) +{ + printf( "fx_change_weather (%2d): P1: %d\n", fx->Opcode, fx->Parameter1 ); + + core->GetGame()->StartRainOrSnow(false, fx->Parameter1 & WB_MASK); + + return FX_NOT_APPLIED; +} + // unknown int fx_unknown (Scriptable* /*Owner*/, Actor* /*target*/, Effect* fx) { diff --git a/project/jni/application/gemrb/src/plugins/FXOpcodes/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/FXOpcodes/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/FXOpcodes/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/FXOpcodes/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/GAMImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/GAMImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/GAMImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/GAMImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/GAMImporter/GAMImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/GAMImporter/GAMImporter.cpp similarity index 89% rename from project/jni/application/gemrb/src/plugins/GAMImporter/GAMImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/GAMImporter/GAMImporter.cpp index b0ea042d1..f757f7fe8 100644 --- a/project/jni/application/gemrb/src/plugins/GAMImporter/GAMImporter.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/GAMImporter/GAMImporter.cpp @@ -31,7 +31,6 @@ #include -#define MAZE_DATA_SIZE 1720 #define FAMILIAR_FILL_SIZE 324 // if your compiler chokes on this, use -1 or 0xff whichever works for you #define UNINITIALIZED_CHAR '\xff' @@ -257,9 +256,13 @@ Game* GAMImporter::LoadGame(Game *newGame, int ver_override) if (version == GAM_VER_PST) { //loading maze if (MazeOffset) { - newGame->mazedata = (ieByte*)malloc(MAZE_DATA_SIZE); + //Don't allocate memory in plugins (MSVC chokes on this) + newGame->AllocateMazeData(); str->Seek(MazeOffset, GEM_STREAM_START ); - str->Read(newGame->mazedata, MAZE_DATA_SIZE); + for (i = 0; imazedata+i*MAZE_ENTRY_SIZE); + } + GetMazeHeader(newGame->mazedata+MAZE_ENTRY_COUNT*MAZE_ENTRY_SIZE); } str->Seek( FamiliarsOffset, GEM_STREAM_START ); } else { @@ -353,7 +356,8 @@ Actor* GAMImporter::GetActor(Holder aM, bool is_in_party ) str->ReadDword( &pcInfo.Interact[i] ); //interact counters } - if (version==GAM_VER_GEMRB || version==GAM_VER_IWD2) { + bool extended = version==GAM_VER_GEMRB || version==GAM_VER_IWD2; + if (extended) { ieResRef tmp; for (i = 0; i < 4; i++) { @@ -499,7 +503,7 @@ Actor* GAMImporter::GetActor(Holder aM, bool is_in_party ) // actor->CreateStats(); PCStatsStruct *ps = actor->PCStats; - GetPCStats(ps); + GetPCStats(ps, extended); memcpy(ps->QSlots, pcInfo.QSlots, sizeof(pcInfo.QSlots) ); memcpy(ps->QuickSpells, pcInfo.QuickSpellResRef, MAX_QSLOTS*sizeof(ieResRef) ); memcpy(ps->QuickSpellClass, pcInfo.QuickSpellClass, MAX_QSLOTS ); @@ -523,7 +527,7 @@ Actor* GAMImporter::GetActor(Holder aM, bool is_in_party ) return actor; } -void GAMImporter::GetPCStats (PCStatsStruct *ps) +void GAMImporter::GetPCStats (PCStatsStruct *ps, bool extended) { int i; @@ -553,6 +557,18 @@ void GAMImporter::GetPCStats (PCStatsStruct *ps) if (core->HasFeature(GF_SOUNDFOLDERS) ) { str->Read( ps->SoundFolder, 32); } + + //iwd2 has some PC only stats that the player can set (this can be done via a guiscript interface) + if (extended) { + //3 - expertise + //4 - power attack + //5 - arterial strike + //6 - hamstring + //7 - rapid shot + for (i=0;i<16;i++) { + str->ReadDword( &ps->ExtraSettings[i] ); + } + } } GAMJournalEntry* GAMImporter::GetJournalEntry() @@ -629,7 +645,8 @@ int GAMImporter::GetStoredFileSize(Game *game) if (game->mazedata) { MazeOffset = headersize; - headersize += MAZE_DATA_SIZE; + //due to alignment the internal size is not the same as the external size + headersize += MAZE_DATA_SIZE_HARDCODED; } else { MazeOffset = 0; } @@ -662,7 +679,11 @@ int GAMImporter::GetStoredFileSize(Game *game) SavedLocOffset = headersize; SavedLocCount = game->GetSavedLocationCount(); - headersize +=SavedLocCount*12; + //there is an unknown dword at the end of iwd2 savegames + if (game->version==GAM_VER_IWD2) { + headersize += 4; + } + headersize += SavedLocCount*12; PPLocOffset = headersize; PPLocCount = game->GetPlaneLocationCount(); @@ -687,10 +708,19 @@ int GAMImporter::PutJournals(DataStream *stream, Game *game) return 0; } -//only in ToB +//only in ToB (and iwd2) int GAMImporter::PutSavedLocations(DataStream *stream, Game *game) { ieWord tmpWord; + ieDword filling = 0; + + //iwd2 has a single 0 dword here (at the end of the file) + //it could be a hacked out saved location list (inherited from SoA) + //if the field is missing, original engine cannot load this saved game + if (game->version==GAM_VER_IWD2) { + stream->WriteDword(&filling); + return 0; + } for (unsigned int i=0;iGetSavedLocationEntry(i); @@ -858,7 +888,7 @@ int GAMImporter::PutActor(DataStream *stream, Actor *ac, ieDword CRESize, ieDwor int i; ieDword tmpDword; ieWord tmpWord; - char filling[194]; + char filling[130]; memset(filling,0,sizeof(filling) ); if (ac->Selected) { @@ -1022,7 +1052,12 @@ int GAMImporter::PutActor(DataStream *stream, Actor *ac, ieDword CRESize, ieDwor stream->Write(ac->PCStats->SoundFolder, 32); } if (version==GAM_VER_IWD2 || version==GAM_VER_GEMRB) { - stream->Write(filling, 194); + //I don't know how many fields are actually used in IWD2 saved game + //but we got at least 8 (and only 5 of those are actually used) + for(i=0;i<16;i++) { + stream->WriteDword( &ac->PCStats->ExtraSettings[i]); + } + stream->Write(filling, 130); } return 0; @@ -1083,9 +1118,75 @@ int GAMImporter::PutNPCs(DataStream *stream, Game *game) return 0; } +void GAMImporter::GetMazeHeader(void *memory) +{ + maze_header *m = (maze_header *) memory; + str->ReadDword( &m->maze_sizex ); + str->ReadDword( &m->maze_sizey ); + str->ReadDword( &m->pos1x ); + str->ReadDword( &m->pos1y ); + str->ReadDword( &m->pos2x ); + str->ReadDword( &m->pos2y ); + str->ReadDword( &m->pos3x ); + str->ReadDword( &m->pos3y ); + str->ReadDword( &m->pos4x ); + str->ReadDword( &m->pos4y ); + str->ReadDword( &m->trapcount ); + str->ReadDword( &m->initialized ); + str->ReadDword( &m->unknown2c ); + str->ReadDword( &m->unknown30 ); +} + +void GAMImporter::GetMazeEntry(void *memory) +{ + maze_entry *h = (maze_entry *) memory; + + str->ReadDword( &h->unknown00 ); + str->ReadDword( &h->valid ); + str->ReadDword( &h->accessible ); + str->ReadDword( &h->traptype ); + str->ReadDword( &h->trapped ); + str->ReadWord( &h->walls ); + str->ReadDword( &h->unknown16 ); +} + +void GAMImporter::PutMazeHeader(DataStream *stream, void *memory) +{ + maze_header *m = (maze_header *) memory; + stream->WriteDword( &m->maze_sizex ); + stream->WriteDword( &m->maze_sizey ); + stream->WriteDword( &m->pos1x ); + stream->WriteDword( &m->pos1y ); + stream->WriteDword( &m->pos2x ); + stream->WriteDword( &m->pos2y ); + stream->WriteDword( &m->pos3x ); + stream->WriteDword( &m->pos3y ); + stream->WriteDword( &m->pos4x ); + stream->WriteDword( &m->pos4y ); + stream->WriteDword( &m->trapcount ); + stream->WriteDword( &m->initialized ); + stream->WriteDword( &m->unknown2c ); + stream->WriteDword( &m->unknown30 ); +} + +void GAMImporter::PutMazeEntry(DataStream *stream, void *memory) +{ + maze_entry *h = (maze_entry *) memory; + stream->WriteDword( &h->unknown00 ); + stream->WriteDword( &h->valid ); + stream->WriteDword( &h->accessible ); + stream->WriteDword( &h->trapped ); + stream->WriteDword( &h->traptype ); + stream->WriteWord( &h->walls ); + stream->WriteDword( &h->unknown16 ); +} + int GAMImporter::PutMaze(DataStream *stream, Game *game) { - stream->Write( game->mazedata, MAZE_DATA_SIZE); + for(int i=0;i<64;i++) { + PutMazeEntry(stream, game->mazedata+i*MAZE_ENTRY_SIZE); + } + PutMazeHeader(stream, game->mazedata+MAZE_ENTRY_COUNT*MAZE_ENTRY_SIZE); return 0; } diff --git a/project/jni/application/gemrb/src/plugins/GAMImporter/GAMImporter.h b/project/jni/application/gemrb/gemrb/plugins/GAMImporter/GAMImporter.h similarity index 91% rename from project/jni/application/gemrb/src/plugins/GAMImporter/GAMImporter.h rename to project/jni/application/gemrb/gemrb/plugins/GAMImporter/GAMImporter.h index a59ee2337..fba05f0fe 100644 --- a/project/jni/application/gemrb/src/plugins/GAMImporter/GAMImporter.h +++ b/project/jni/application/gemrb/gemrb/plugins/GAMImporter/GAMImporter.h @@ -59,7 +59,7 @@ public: int PutGame(DataStream *stream, Game *game); private: Actor* GetActor(Holder aM, bool is_in_party ); - void GetPCStats(PCStatsStruct* ps); + void GetPCStats(PCStatsStruct* ps, bool extended); GAMJournalEntry* GetJournalEntry(); int PutHeader(DataStream *stream, Game *game); @@ -69,6 +69,10 @@ private: int PutJournals(DataStream *stream, Game *game); int PutVariables( DataStream *stream, Game *game); int PutKillVars(DataStream *stream, Game *game); + void GetMazeHeader(void *memory); + void GetMazeEntry(void *memory); + void PutMazeHeader(DataStream *stream, void *memory); + void PutMazeEntry(DataStream *stream, void *memory); int PutMaze(DataStream *stream, Game *game); int PutFamiliars(DataStream *stream, Game *game); int PutSavedLocations(DataStream *stream, Game *game); diff --git a/project/jni/application/gemrb/src/plugins/GAMImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/GAMImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/GAMImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/GAMImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/GUIScript/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/GUIScript/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/GUIScript/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/GUIScript/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/GUIScript/GUIScript.cpp b/project/jni/application/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp similarity index 97% rename from project/jni/application/gemrb/src/plugins/GUIScript/GUIScript.cpp rename to project/jni/application/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp index 609df9a1b..18ccf9ff1 100644 --- a/project/jni/application/gemrb/src/plugins/GUIScript/GUIScript.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp @@ -77,7 +77,6 @@ GUIScript *gs = NULL; #define METHOD(name, args) {#name, GemRB_ ## name, args, GemRB_ ## name ## __doc} static int SpecialItemsCount = -1; -static int SpecialSpellsCount = -1; static int StoreSpellsCount = -1; static int UsedItemsCount = -1; static int ItemSoundsCount = -1; @@ -87,6 +86,9 @@ static int ItemSoundsCount = -1; #define CRI_EQUIP 1 #define CRI_SWAP 2 +//bit used in SetCreatureStat to access some fields +#define EXTRASETTINGS 0x1000 + struct UsedItemType { ieResRef itemname; ieVariable username; //death variable @@ -94,24 +96,15 @@ struct UsedItemType { int flags; }; -struct SpellDescType { - ieResRef resref; - ieStrRef value; -}; - typedef char EventNameType[17]; -#define IS_DROP 0 -#define IS_GET 1 +#define IS_DROP 0 +#define IS_GET 1 typedef ieResRef ResRefPairs[2]; #define UNINIT_IEDWORD 0xcccccccc static SpellDescType *SpecialItems = NULL; -static SpellDescType *SpecialSpells = NULL; - -#define SP_IDENTIFY 1 //any spell that cannot be cast from the menu -#define SP_SILENCE 2 //any spell that can be cast in silence static SpellDescType *StoreSpells = NULL; static ItemExtHeader *ItemArray = NULL; @@ -276,6 +269,16 @@ static inline bool CheckStat(Actor * actor, ieDword stat, ieDword value, int op) static int GetCreatureStat(Actor *actor, unsigned int StatID, int Mod) { + //this is a hack, if more PCStats fields are needed, improve it + if (StatID&EXTRASETTINGS) { + PCStatsStruct *ps = actor->PCStats; + if (!ps) { + //the official invalid value in GetStat + return 0xdadadada; + } + StatID&=15; + return ps->ExtraSettings[StatID]; + } if (Mod) { return actor->GetStat( StatID ); } @@ -284,6 +287,17 @@ static int GetCreatureStat(Actor *actor, unsigned int StatID, int Mod) static int SetCreatureStat(Actor *actor, unsigned int StatID, int StatValue, bool pcf) { + //this is a hack, if more PCStats fields are needed, improve it + if (StatID&EXTRASETTINGS) { + PCStatsStruct *ps = actor->PCStats; + if (!ps) { + return 0; + } + StatID&=15; + ps->ExtraSettings[StatID] = StatValue; + return 1; + } + if (pcf) { actor->SetBase( StatID, StatValue ); } else { @@ -1310,6 +1324,43 @@ static PyObject* GemRB_TextEdit_SetBufferLength(PyObject * /*self*/, PyObject* a return Py_None; } +PyDoc_STRVAR( GemRB_TextArea_SelectText__doc, +"SelectText(WindowIndex, ControlIndex, String|Strref) => void\n\n" +"Tries to set the Variable of the TextArea control to the linenumber of the referenced string."); + +static PyObject* GemRB_TextArea_SelectText(PyObject * /*self*/, PyObject* args) +{ + PyObject* wi, * ci, * str; + long WindowIndex, ControlIndex; + char* string; + + if (!PyArg_UnpackTuple( args, "ref", 3, 3, &wi, &ci, &str )) { + return AttributeError( GemRB_TextArea_SelectText__doc ); + } + + if (!PyObject_TypeCheck( wi, &PyInt_Type ) || + !PyObject_TypeCheck( ci, &PyInt_Type ) || + ( !PyObject_TypeCheck( str, &PyString_Type ) && + !PyObject_TypeCheck( str, &PyInt_Type ) )) { + return AttributeError( GemRB_TextArea_SelectText__doc ); + } + + WindowIndex = PyInt_AsLong( wi ); + ControlIndex = PyInt_AsLong( ci ); + if (PyObject_TypeCheck( str, &PyString_Type )) { + string = PyString_AsString( str ); + if (string == NULL) { + return RuntimeError("Null string received"); + } + TextArea* ta = (TextArea *) GetControl( WindowIndex, ControlIndex, IE_GUI_TEXTAREA ); + if (!ta) + return NULL; + ta->SelectText( string ); + } + Py_INCREF( Py_None ); + return Py_None; +} + PyDoc_STRVAR( GemRB_Control_SetText__doc, "SetText(WindowIndex, ControlIndex, String|Strref) => int\n\n" "Sets the Text of a control in a Window." ); @@ -2444,7 +2495,7 @@ static PyObject* GemRB_AddNewArea(PyObject * /*self*/, PyObject* args) links[WMP_WEST] = atoi(newarea->QueryField(i,12)); //this is the number of links in the 2da, we don't need it int linksto = atoi(newarea->QueryField(i,13)); - + unsigned int local = 0; int linkcnt = wmap->GetLinkCount(); for (k=0;k<4;k++) { @@ -2472,7 +2523,7 @@ static PyObject* GemRB_AddNewArea(PyObject * /*self*/, PyObject* args) memset(entry->LoadScreenResRef, 0, 8); memcpy(entry->AreaLinksIndex, indices, sizeof(entry->AreaLinksIndex) ); memcpy(entry->AreaLinksCount, links, sizeof(entry->AreaLinksCount) ); - + int thisarea = wmap->GetEntryCount(); wmap->AddAreaEntry(entry); wmap->AreaEntriesCount++; @@ -2918,7 +2969,7 @@ static PyObject* GemRB_GameGetExpansion(PyObject * /*self*/, PyObject* /*args*/) Game *game = core->GetGame(); if (!game) { return RuntimeError( "No game loaded!" ); - } + } return PyInt_FromLong( game->Expansion ); } @@ -3250,8 +3301,6 @@ static PyObject* GemRB_Button_SetSprite2D(PyObject * /*self*/, PyObject* args) CObject spr(obj); - if (spr) - spr->acquire(); btn->SetPicture( spr.get() ); Py_INCREF( Py_None ); @@ -4393,11 +4442,11 @@ PyDoc_STRVAR( GemRB_SetJournalEntry__doc, static PyObject* GemRB_SetJournalEntry(PyObject * /*self*/, PyObject * args) { - int section=-1, chapter = -1, strref; + int section=-1, chapter = -1, strref; - if (!PyArg_ParseTuple( args, "i|ii", &strref, §ion, &chapter )) { - return AttributeError( GemRB_SetJournalEntry__doc ); - } + if (!PyArg_ParseTuple( args, "i|ii", &strref, §ion, &chapter )) { + return AttributeError( GemRB_SetJournalEntry__doc ); + } Game *game = core->GetGame(); if (!game) { @@ -4421,8 +4470,8 @@ static PyObject* GemRB_SetJournalEntry(PyObject * /*self*/, PyObject * args) game->AddJournalEntry( chapter, section, strref); } - Py_INCREF( Py_None ); - return Py_None; + Py_INCREF( Py_None ); + return Py_None; } PyDoc_STRVAR( GemRB_GameIsBeastKnown__doc, @@ -6201,60 +6250,6 @@ static PyObject* GemRB_GetStoreDrink(PyObject * /*self*/, PyObject* args) return dict; } -static void ReadSpecialSpells() -{ - int i; - - SpecialSpellsCount = 0; - int table = gamedata->LoadTable("splspec"); - if (table>=0) { - Holder tab = gamedata->GetTable(table); - if (!tab) goto table_loaded; - SpecialSpellsCount = tab->GetRowCount(); - SpecialSpells = (SpellDescType *) malloc( sizeof(SpellDescType) * SpecialSpellsCount); - for (i=0;iGetRowName(i),8 ); - //if there are more flags, compose this value into a bitfield - SpecialSpells[i].value = atoi(tab->QueryField(i,0) ); - } -table_loaded: - gamedata->DelTable(table); - } -} - -int GetSpecialSpell(ieResRef resref) -{ - if (SpecialSpellsCount==-1) { - ReadSpecialSpells(); - } - for (int i=0;iGetStat(IE_STATE_ID) & STATE_SILENCED ) { - if (!(sp&SP_SILENCE)) { - return 1; - } - } - - return 0; -} - static void ReadUsedItems() { int i; @@ -8348,7 +8343,7 @@ static PyObject* GemRB_Window_SetupSpellIcons(PyObject * /*self*/, PyObject* arg // Identify is misclassified and has Target 3 (Dead char) ieDword spelltype = ResolveSpellNumber(spell->spellname)/1000; - if (CheckSpecialSpell(spell->spellname, actor) || (disabled_spellcasting&(1<CheckSpecialSpell(spell->spellname, actor) || (disabled_spellcasting&(1<SetState(IE_GUI_BUTTON_DISABLED); btn->EnableBorder(1, IE_GUI_BUTTON_DISABLED); PyObject *Function = PyDict_GetItemString(dict, "UpdateActionsWindow"); @@ -8923,13 +8918,14 @@ static PyObject* GemRB_SetModalState(PyObject * /*self*/, PyObject* args) PyDoc_STRVAR( GemRB_SpellCast__doc, "SpellCast(slot, type, spell[, global])\n\n" "Makes the actor try to cast a spell. Type is the spell type like 3 for normal spells and 4 for innates.\n" +"If type is -1, then the castable spell list will be deleted and no spell will be cast.\n" "Spell is the index of the spell in the memorised spell list.\n" -"If global is set, the actor will be looked up by its global ID instead of party slot."); +"If global is set, the actor will be looked up by its global ID instead of party slot.\n"); static PyObject* GemRB_SpellCast(PyObject * /*self*/, PyObject* args) { unsigned int slot; - unsigned int type; + int type; unsigned int spell; int global = 0; @@ -8950,6 +8946,13 @@ static PyObject* GemRB_SpellCast(PyObject * /*self*/, PyObject* args) return RuntimeError( "Actor not found" ); } + //don't cast anything, just reinit the spell list + if (type==-1) { + actor->spellbook.ClearSpellInfo(); + Py_INCREF( Py_None ); + return Py_None; + } + SpellExtHeader spelldata; // = SpellArray[spell]; actor->spellbook.GetSpellInfo(&spelldata, type, spell, 1); @@ -8970,23 +8973,23 @@ static PyObject* GemRB_SpellCast(PyObject * /*self*/, PyObject* args) switch (spelldata.Target) { case TARGET_SELF: // FIXME: GA_NO_DEAD and such are not actually used by SetupCasting - gc->SetupCasting(spelldata.type, spelldata.level, spelldata.slot, actor, GA_NO_DEAD, spelldata.TargetNumber); + gc->SetupCasting(spelldata.spellname, spelldata.type, spelldata.level, spelldata.slot, actor, GA_NO_DEAD, spelldata.TargetNumber); gc->TryToCast(actor, actor); break; case TARGET_NONE: //reset the cursor gc->ResetTargetMode(); - //this is always instant casting + //this is always instant casting without spending the spell core->ApplySpell(spelldata.spellname, actor, actor, 0); break; case TARGET_AREA: - gc->SetupCasting(spelldata.type, spelldata.level, spelldata.slot, actor, GA_POINT, spelldata.TargetNumber); + gc->SetupCasting(spelldata.spellname, spelldata.type, spelldata.level, spelldata.slot, actor, GA_POINT, spelldata.TargetNumber); break; case TARGET_CREA: - gc->SetupCasting(spelldata.type, spelldata.level, spelldata.slot, actor, GA_NO_DEAD, spelldata.TargetNumber); + gc->SetupCasting(spelldata.spellname, spelldata.type, spelldata.level, spelldata.slot, actor, GA_NO_DEAD, spelldata.TargetNumber); break; case TARGET_DEAD: - gc->SetupCasting(spelldata.type, spelldata.level, spelldata.slot, actor, 0, spelldata.TargetNumber); + gc->SetupCasting(spelldata.spellname, spelldata.type, spelldata.level, spelldata.slot, actor, 0, spelldata.TargetNumber); break; case TARGET_INV: //bring up inventory in the end??? @@ -9286,9 +9289,6 @@ static PyObject* GemRB_HasSpecialSpell(PyObject * /*self*/, PyObject* args) if (!PyArg_ParseTuple( args, "iii", &PartyID, &itemtype, &useup)) { return AttributeError( GemRB_HasSpecialSpell__doc ); } - if (SpecialSpellsCount==-1) { - ReadSpecialSpells(); - } Game *game = core->GetGame(); if (!game) { @@ -9298,10 +9298,14 @@ static PyObject* GemRB_HasSpecialSpell(PyObject * /*self*/, PyObject* args) if (!actor) { return RuntimeError( "Actor not found" ); } - int i = SpecialSpellsCount; + int i = core->GetSpecialSpellsCount(); + if (i == -1) { + return RuntimeError( "Game has no splspec.2da table!" ); + } + SpellDescType *special_spells = core->GetSpecialSpells(); while(i--) { - if (itemtype&SpecialSpells[i].value) { - if (actor->spellbook.HaveSpell(SpecialSpells[i].resref,useup)) { + if (itemtype&special_spells[i].value) { + if (actor->spellbook.HaveSpell(special_spells[i].resref,useup)) { if (useup) { //actor->SpellCast(SpecialSpells[i].resref, actor); } @@ -9584,7 +9588,7 @@ static PyObject* GemRB_GetCombatDetails(PyObject * /*self*/, PyObject* args) int speed, style=0; PyObject* dict = PyDict_New(); - if (!actor->GetCombatDetails(tohit, leftorright, wi, header, hittingheader, Flags, DamageBonus, speed, CriticalBonus, style)) { + if (!actor->GetCombatDetails(tohit, leftorright, wi, header, hittingheader, Flags, DamageBonus, speed, CriticalBonus, style, NULL)) { //TODO: handle error, so tohit will still be set correctly? } PyDict_SetItemString(dict, "ToHit", PyInt_FromLong (tohit)); @@ -9706,6 +9710,204 @@ static PyObject* GemRB_SetTickHook(PyObject* /*self*/, PyObject* args) return Py_None; } +PyDoc_STRVAR( GemRB_SetupMaze__doc, +"SetupMaze(x,y)\n\n" +"Initializes a maze of XxY size. " +"The dimensions shouldn't exceed the maximum possible maze size (8x8)."); + +static PyObject* GemRB_SetupMaze(PyObject* /*self*/, PyObject* args) +{ + int xsize, ysize; + + if (!PyArg_ParseTuple( args, "ii", &xsize, &ysize )) { + return AttributeError( GemRB_SetupMaze__doc ); + } + + if ((unsigned) xsize>MAZE_MAX_DIM || (unsigned) ysize>MAZE_MAX_DIM) { + return AttributeError( GemRB_SetupMaze__doc ); + } + + Game *game = core->GetGame(); + if (!game) { + return RuntimeError( "No game loaded!" ); + } + + maze_header *h = (maze_header *) (game->AllocateMazeData()+MAZE_ENTRY_COUNT*MAZE_ENTRY_SIZE); + memset(h, 0, MAZE_HEADER_SIZE); + h->maze_sizex = xsize; + h->maze_sizey = ysize; + for(int i=0;imazedata+i*MAZE_ENTRY_SIZE); + memset(m, 0, MAZE_ENTRY_SIZE); + bool used = (i/MAZE_MAX_DIMvalid = used; + m->accessible = used; + } + Py_INCREF(Py_None); + return Py_None; +} + +PyDoc_STRVAR( GemRB_SetMazeEntry__doc, +"SetMazeEntry(entry, type, value)\n\n" +"Sets a field in a maze entry. " +"The entry index shouldn't exceed the maximum possible maze size (64). " +"The type could be: ME_0, ME_WALLS, ME_TRAP or ME_16."); + +static PyObject* GemRB_SetMazeEntry(PyObject* /*self*/, PyObject* args) +{ + int entry; + int index; + int value; + + if (!PyArg_ParseTuple( args, "iii", &entry, &index, &value )) { + return AttributeError( GemRB_SetMazeEntry__doc ); + } + + if (entry<0 || entry>63) { + return AttributeError( GemRB_SetMazeEntry__doc ); + } + + Game *game = core->GetGame(); + if (!game) { + return RuntimeError( "No game loaded!" ); + } + + if (!game->mazedata) { + return RuntimeError( "No maze set up!" ); + } + + maze_header *h = (maze_header *) (game->mazedata+MAZE_ENTRY_COUNT*MAZE_ENTRY_SIZE); + int dims = h->maze_sizex; + maze_entry *m = (maze_entry *) (game->mazedata+entry*MAZE_ENTRY_SIZE); + maze_entry *m2; + switch(index) { + case ME_0: //unknown00 + m->unknown00 = value; + break; + default: + case ME_VALID: + case ME_ACCESSIBLE: + return AttributeError( GemRB_SetMazeEntry__doc ); + break; + case ME_TRAP: //trapped/traptype + if (value==-1) { + m->trapped = 0; + m->traptype = 0; + } else { + m->trapped = 1; + m->traptype = value; + } + break; + case ME_WALLS: + m->walls |= value; + if (value & WALL_EAST) { + if (entry%dims!=dims-1) { + m2 = (maze_entry *) (game->mazedata+(entry+1)*MAZE_ENTRY_SIZE); + m2->walls|=WALL_WEST; + } + } + + if (value & WALL_WEST) { + if (entry%dims) { + m2 = (maze_entry *) (game->mazedata+(entry-1)*MAZE_ENTRY_SIZE); + m2->walls|=WALL_EAST; + } + } + + if (value & WALL_NORTH) { + if (entry>=dims) { + m2 = (maze_entry *) (game->mazedata+(entry-dims)*MAZE_ENTRY_SIZE); + m2->walls|=WALL_SOUTH; + } + } + + if (value & WALL_SOUTH) { + if (entry+dimsmazedata+(entry+dims)*MAZE_ENTRY_SIZE); + m2->walls|=WALL_SOUTH; + } + } + + break; + case ME_16: + m->unknown16 = value; + break; + } + + Py_INCREF(Py_None); + return Py_None; +} + +PyDoc_STRVAR( GemRB_SetMazeData__doc, +"SetMazeData(type, value)\n\n" +"Sets a field in the maze header. " +"The type could be: ME_0, ME_WALLS, ME_TRAP or ME_16."); + +static PyObject* GemRB_SetMazeData(PyObject* /*self*/, PyObject* args) +{ + int entry; + int value; + + if (!PyArg_ParseTuple( args, "ii", &entry, &value )) { + return AttributeError( GemRB_SetMazeData__doc ); + } + + Game *game = core->GetGame(); + if (!game) { + return RuntimeError( "No game loaded!" ); + } + + if (!game->mazedata) { + return RuntimeError( "No maze set up!" ); + } + + + maze_header *h = (maze_header *) (game->mazedata+MAZE_ENTRY_COUNT*MAZE_ENTRY_SIZE); + switch(entry) { + case MH_POS1X: + h->pos1x = value; + break; + case MH_POS1Y: + h->pos1y = value; + break; + case MH_POS2X: + h->pos2x = value; + break; + case MH_POS2Y: + h->pos2y = value; + break; + case MH_POS3X: + h->pos3x = value; + break; + case MH_POS3Y: + h->pos3y = value; + break; + case MH_POS4X: + h->pos4x = value; + break; + case MH_POS4Y: + h->pos4y = value; + break; + case MH_TRAPCOUNT: + h->trapcount = value; + break; + case MH_INITED: + h->initialized = value; + break; + case MH_UNKNOWN2C: + h->unknown2c = value; + break; + case MH_UNKNOWN30: + h->unknown30 = value; + break; + default: + return AttributeError( GemRB_SetMazeData__doc ); + } + + Py_INCREF(Py_None); + return Py_None; +} + static PyMethodDef GemRBMethods[] = { METHOD(ActOnPC, METH_VARARGS), METHOD(AddNewArea, METH_VARARGS), @@ -9858,6 +10060,8 @@ static PyMethodDef GemRBMethods[] = { METHOD(SetJournalEntry, METH_VARARGS), METHOD(SetMapnote, METH_VARARGS), METHOD(SetMasterScript, METH_VARARGS), + METHOD(SetMazeEntry, METH_VARARGS), + METHOD(SetMazeData, METH_VARARGS), METHOD(SetMemorizableSpellsCount, METH_VARARGS), METHOD(SetModalState, METH_VARARGS), METHOD(SetMouseScrollSpeed, METH_VARARGS), @@ -9873,6 +10077,7 @@ static PyMethodDef GemRBMethods[] = { METHOD(SetTimedEvent, METH_VARARGS), METHOD(SetToken, METH_VARARGS), METHOD(SetTooltipDelay, METH_VARARGS), + METHOD(SetupMaze, METH_VARARGS), METHOD(SetupQuickSlot, METH_VARARGS), METHOD(SetVar, METH_VARARGS), METHOD(SoftEndPL, METH_NOARGS), @@ -9950,6 +10155,7 @@ static PyMethodDef GemRBInternalMethods[] = { METHOD(TextArea_MoveText, METH_VARARGS), METHOD(TextArea_Rewind, METH_VARARGS), METHOD(TextArea_Scroll, METH_VARARGS), + METHOD(TextArea_SelectText, METH_VARARGS), METHOD(TextArea_SetHistory, METH_VARARGS), METHOD(TextEdit_ConvertEdit, METH_VARARGS), METHOD(TextEdit_SetBufferLength, METH_VARARGS), @@ -10008,10 +10214,6 @@ GUIScript::~GUIScript(void) free(StoreSpells); StoreSpells=NULL; } - if (SpecialSpells) { - free(SpecialSpells); - SpecialSpells=NULL; - } if (SpecialItems) { free(SpecialItems); SpecialItems=NULL; @@ -10026,7 +10228,6 @@ GUIScript::~GUIScript(void) } StoreSpellsCount = -1; - SpecialSpellsCount = -1; SpecialItemsCount = -1; UsedItemsCount = -1; ItemSoundsCount = -1; diff --git a/project/jni/application/gemrb/src/plugins/GUIScript/GUIScript.h b/project/jni/application/gemrb/gemrb/plugins/GUIScript/GUIScript.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/GUIScript/GUIScript.h rename to project/jni/application/gemrb/gemrb/plugins/GUIScript/GUIScript.h diff --git a/project/jni/application/gemrb/src/plugins/GUIScript/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/GUIScript/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/GUIScript/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/GUIScript/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/GUIScript/PythonHelpers.cpp b/project/jni/application/gemrb/gemrb/plugins/GUIScript/PythonHelpers.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/GUIScript/PythonHelpers.cpp rename to project/jni/application/gemrb/gemrb/plugins/GUIScript/PythonHelpers.cpp diff --git a/project/jni/application/gemrb/src/plugins/GUIScript/PythonHelpers.h b/project/jni/application/gemrb/gemrb/plugins/GUIScript/PythonHelpers.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/GUIScript/PythonHelpers.h rename to project/jni/application/gemrb/gemrb/plugins/GUIScript/PythonHelpers.h diff --git a/project/jni/application/gemrb/src/plugins/IDSImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/IDSImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/IDSImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/IDSImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/IDSImporter/IDSImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/IDSImporter/IDSImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/IDSImporter/IDSImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/IDSImporter/IDSImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/IDSImporter/IDSImporter.h b/project/jni/application/gemrb/gemrb/plugins/IDSImporter/IDSImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/IDSImporter/IDSImporter.h rename to project/jni/application/gemrb/gemrb/plugins/IDSImporter/IDSImporter.h diff --git a/project/jni/application/gemrb/src/plugins/IDSImporter/IDSImporterDefs.h b/project/jni/application/gemrb/gemrb/plugins/IDSImporter/IDSImporterDefs.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/IDSImporter/IDSImporterDefs.h rename to project/jni/application/gemrb/gemrb/plugins/IDSImporter/IDSImporterDefs.h diff --git a/project/jni/application/gemrb/src/plugins/IDSImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/IDSImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/IDSImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/IDSImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/INIImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/INIImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/INIImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/INIImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/INIImporter/INIImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/INIImporter/INIImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/INIImporter/INIImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/INIImporter/INIImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/INIImporter/INIImporter.h b/project/jni/application/gemrb/gemrb/plugins/INIImporter/INIImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/INIImporter/INIImporter.h rename to project/jni/application/gemrb/gemrb/plugins/INIImporter/INIImporter.h diff --git a/project/jni/application/gemrb/src/plugins/INIImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/INIImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/INIImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/INIImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/ITMImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/ITMImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/ITMImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/ITMImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/ITMImporter/ITMImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/ITMImporter/ITMImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/ITMImporter/ITMImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/ITMImporter/ITMImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/ITMImporter/ITMImporter.h b/project/jni/application/gemrb/gemrb/plugins/ITMImporter/ITMImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/ITMImporter/ITMImporter.h rename to project/jni/application/gemrb/gemrb/plugins/ITMImporter/ITMImporter.h diff --git a/project/jni/application/gemrb/src/plugins/ITMImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/ITMImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/ITMImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/ITMImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/IWDOpcodes/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/IWDOpcodes/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/IWDOpcodes/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/IWDOpcodes/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/IWDOpcodes/IWDOpcodes.cpp b/project/jni/application/gemrb/gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp similarity index 98% rename from project/jni/application/gemrb/src/plugins/IWDOpcodes/IWDOpcodes.cpp rename to project/jni/application/gemrb/gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp index b46d22152..5efe18cf7 100644 --- a/project/jni/application/gemrb/src/plugins/IWDOpcodes/IWDOpcodes.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp @@ -41,7 +41,6 @@ static bool enhanced_effects = false; //a scripting object for enemy (used for enemy in line of sight check) static Trigger *Enemy = NULL; -#define PI_CONFUSION 3 #define PI_PROTFROMEVIL 9 #define PI_FREEACTION 19 #define PI_BARKSKIN 20 @@ -116,14 +115,14 @@ static int fx_umberhulk_gaze (Scriptable* Owner, Actor* target, Effect* fx); //1 static int fx_zombielord_aura (Scriptable* Owner, Actor* target, Effect* fx); //101, duff in iwd2 static int fx_resist_spell (Scriptable* Owner, Actor* target, Effect* fx); //102 static int fx_summon_creature2 (Scriptable* Owner, Actor* target, Effect* fx); //103 -//int fx_avatar_removal (Scriptable* Owner, Actor* target, Effect* fx); //104 +static int fx_avatar_removal (Scriptable* Owner, Actor* target, Effect* fx); //104 //int fx_immunity_effect2 (Scriptable* Owner, Actor* target, Effect* fx); //105 static int fx_summon_pomab (Scriptable* Owner, Actor* target, Effect* fx); //106 static int fx_control_undead (Scriptable* Owner, Actor* target, Effect* fx); //107 static int fx_static_charge (Scriptable* Owner, Actor* target, Effect* fx); //108 static int fx_cloak_of_fear (Scriptable* Owner, Actor* target, Effect* fx); //109 //int fx_movement_modifier (Scriptable* Owner, Actor* target, Effect* fx); //10a -static int fx_remove_confusion (Scriptable* Owner, Actor* target, Effect* fx);//10b +//int fx_remove_confusion (Scriptable* Owner, Actor* target, Effect* fx);//10b static int fx_eye_of_the_mind (Scriptable* Owner, Actor* target, Effect* fx);//10c static int fx_eye_of_the_sword (Scriptable* Owner, Actor* target, Effect* fx);//10d static int fx_eye_of_the_mage (Scriptable* Owner, Actor* target, Effect* fx);//10e @@ -255,11 +254,11 @@ static EffectRef effectnames[] = { { "UmberHulkGaze", fx_umberhulk_gaze, -1}, //100 { "ZombieLordAura", fx_zombielord_aura, -1},//101, duff in iwd2 { "SummonCreature2", fx_summon_creature2, -1}, //103 + { "AvatarRemoval", fx_avatar_removal, -1}, //104 { "SummonPomab", fx_summon_pomab, -1}, //106 { "ControlUndead", fx_control_undead, -1}, //107 { "StaticCharge", fx_static_charge, -1}, //108 { "CloakOfFear", fx_cloak_of_fear, -1}, //109 how/iwd2 - { "RemoveConfusion", fx_remove_confusion, -1},//10b { "EyeOfTheMind", fx_eye_of_the_mind, -1}, //10c { "EyeOfTheSword", fx_eye_of_the_sword, -1}, //10d { "EyeOfTheMage", fx_eye_of_the_mage, -1}, //10e @@ -1204,6 +1203,13 @@ int fx_salamander_aura (Scriptable* Owner, Actor* target, Effect* fx) return FX_NOT_APPLIED; } + //timing + ieDword time = core->GetGame()->GameTime; + if ((fx->Parameter4==time) || (time%6) ) { + return FX_APPLIED; + } + fx->Parameter4=time; + ieDword damage = DAMAGE_FIRE; if (fx->Parameter2==1) { @@ -1218,7 +1224,6 @@ int fx_salamander_aura (Scriptable* Owner, Actor* target, Effect* fx) //it is a specially hacked effect to ignore certain races //from the confusion effect static EffectRef fx_confusion_ref={"State:Confused",NULL,-1}; -static EffectRef fx_display_portrait_icon_ref={"Icon:Display",NULL,-1}; static EffectRef fx_immunity_resource_ref={"Protection:Spell",NULL,-1}; int fx_umberhulk_gaze (Scriptable* Owner, Actor* target, Effect* fx) @@ -1366,7 +1371,13 @@ int fx_summon_creature2 (Scriptable* Owner, Actor* target, Effect* fx) return FX_NOT_APPLIED; } -//0x104 AvatarRemovalModifier (same as bg2) +//0x104 AvatarRemoval +int fx_avatar_removal (Scriptable* /*Owner*/, Actor* target, Effect* /*fx*/) +{ + BASE_SET(IE_AVATARREMOVAL, 1); + return FX_NOT_APPLIED; +} + //0x105 immunity to effect (same as bg2?) //0x106 SummonPomab @@ -1542,16 +1553,8 @@ int fx_cloak_of_fear(Scriptable* Owner, Actor* target, Effect* fx) } //0x10a MovementRateModifier3 (Like bg2) -//0x10b RemoveConfusion -int fx_remove_confusion (Scriptable* /*Owner*/, Actor* target, Effect* fx) -{ - if (0) printf( "fx_remove_confusion (%2d)\n", fx->Opcode ); - BASE_STATE_CURE(STATE_CONFUSED); - target->fxqueue.RemoveAllEffects(fx_confusion_ref); - target->fxqueue.RemoveAllEffects(fx_umberhulk_gaze_ref); - target->fxqueue.RemoveAllEffectsWithParam(fx_display_portrait_icon_ref,PI_CONFUSION); - return FX_APPLIED; -} +//0x10b Cure:Confusion (Like bg2) + //0x10c EyeOfTheMind int fx_eye_of_the_mind (Scriptable* /*Owner*/, Actor* target, Effect* fx) { @@ -1730,10 +1733,26 @@ int fx_shroud_of_flame (Scriptable* Owner, Actor* target, Effect* fx) return FX_NOT_APPLIED; } - //timing - if (core->GetGame()->GameTime%6) { + //don't apply it twice in a round + if (EXTSTATE_GET(EXTSTATE_SHROUD)) { return FX_APPLIED; } + EXTSTATE_SET(EXTSTATE_SHROUD); + //directly modifying the color of the target + if (fx->Parameter2==1) { + target->SetColorMod(0xff, RGBModifier::ADD, -1, 0, 0, 0x96); + } + else { + target->SetColorMod(0xff, RGBModifier::ADD, -1, 0x96, 0, 0); + } + + //timing + ieDword time = core->GetGame()->GameTime; + if ((fx->Parameter4==time) || (time%6) ) { + return FX_APPLIED; + } + fx->Parameter4=time; + //inflicts damage calculated by dice values+parameter1 //creates damage opcode on everyone around. fx->Parameter2 - 0 fire, 1 - ice ieDword damage = DAMAGE_FIRE; @@ -1742,13 +1761,16 @@ int fx_shroud_of_flame (Scriptable* Owner, Actor* target, Effect* fx) damage = DAMAGE_COLD; } - target->Damage(fx->Parameter1, DAMAGE_FIRE, Owner); - ApplyDamageNearby(Owner, target, fx, DAMAGE_FIRE); + target->Damage(fx->Parameter1, damage, Owner); + ApplyDamageNearby(Owner, target, fx, damage); return FX_APPLIED; } +static ieResRef resref_sof1={"effsof1"}; +static ieResRef resref_sof2={"effsof2"}; + //0x116 ShroudOfFlame (iwd2) -int fx_shroud_of_flame2 (Scriptable* /*Owner*/, Actor* target, Effect* fx) +int fx_shroud_of_flame2 (Scriptable* Owner, Actor* target, Effect* fx) { if (0) printf( "fx_shroud_of_flame2 (%2d)\n", fx->Opcode ); @@ -1758,18 +1780,32 @@ int fx_shroud_of_flame2 (Scriptable* /*Owner*/, Actor* target, Effect* fx) } if (target->SetSpellState( SS_FLAMESHROUD)) return FX_APPLIED; + EXTSTATE_SET(EXTSTATE_SHROUD); //just for compatibility if(enhanced_effects) { target->SetColorMod(0xff, RGBModifier::ADD, 1, 0xa0, 0, 0); } - //timing - //if (core->GetGame()->GameTime%6) { - // return FX_APPLIED; - //} - //apply resource on hitter - memcpy(target->applyWhenBeingHit,fx->Resource,sizeof(ieResRef)); + //actually, this should be a list of triggers + if (fx->Resource[0]) { + memcpy(target->applyWhenBeingHit,fx->Resource,sizeof(ieResRef)); + } else { + memcpy(target->applyWhenBeingHit,resref_sof1,sizeof(ieResRef)); + } + + //timing + ieDword time = core->GetGame()->GameTime; + if ((fx->Parameter4==time) || (time%6) ) { + return FX_APPLIED; + } + fx->Parameter4=time; + + if (fx->Resource2[0]) { + core->ApplySpell(fx->Resource2, target, Owner, fx->Power); + } else { + core->ApplySpell(resref_sof2, target, Owner, fx->Power); + } return FX_APPLIED; } diff --git a/project/jni/application/gemrb/src/plugins/IWDOpcodes/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/IWDOpcodes/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/IWDOpcodes/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/IWDOpcodes/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/KEYImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/KEYImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/KEYImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/KEYImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/KEYImporter/Dictionary.cpp b/project/jni/application/gemrb/gemrb/plugins/KEYImporter/Dictionary.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/KEYImporter/Dictionary.cpp rename to project/jni/application/gemrb/gemrb/plugins/KEYImporter/Dictionary.cpp diff --git a/project/jni/application/gemrb/src/plugins/KEYImporter/Dictionary.h b/project/jni/application/gemrb/gemrb/plugins/KEYImporter/Dictionary.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/KEYImporter/Dictionary.h rename to project/jni/application/gemrb/gemrb/plugins/KEYImporter/Dictionary.h diff --git a/project/jni/application/gemrb/src/plugins/KEYImporter/KEYImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/KEYImporter/KEYImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/KEYImporter/KEYImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/KEYImporter/KEYImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/KEYImporter/KEYImporter.h b/project/jni/application/gemrb/gemrb/plugins/KEYImporter/KEYImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/KEYImporter/KEYImporter.h rename to project/jni/application/gemrb/gemrb/plugins/KEYImporter/KEYImporter.h diff --git a/project/jni/application/gemrb/src/plugins/KEYImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/KEYImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/KEYImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/KEYImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/MOSImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/MOSImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/MOSImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/MOSImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/MOSImporter/MOSImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/MOSImporter/MOSImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/MOSImporter/MOSImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/MOSImporter/MOSImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/MOSImporter/MOSImporter.h b/project/jni/application/gemrb/gemrb/plugins/MOSImporter/MOSImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/MOSImporter/MOSImporter.h rename to project/jni/application/gemrb/gemrb/plugins/MOSImporter/MOSImporter.h diff --git a/project/jni/application/gemrb/src/plugins/MOSImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/MOSImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/MOSImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/MOSImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/MUSImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/MUSImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/MUSImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/MUSImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/MUSImporter/MUSImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/MUSImporter/MUSImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/MUSImporter/MUSImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/MUSImporter/MUSImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/MUSImporter/MUSImporter.h b/project/jni/application/gemrb/gemrb/plugins/MUSImporter/MUSImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/MUSImporter/MUSImporter.h rename to project/jni/application/gemrb/gemrb/plugins/MUSImporter/MUSImporter.h diff --git a/project/jni/application/gemrb/src/plugins/MUSImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/MUSImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/MUSImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/MUSImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/MVEPlayer.cpp b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/MVEPlayer.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/MVEPlayer.cpp rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/MVEPlayer.cpp diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/MVEPlayer.h b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/MVEPlayer.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/MVEPlayer.h rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/MVEPlayer.h diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/gstmvedemux.h b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/gstmvedemux.h similarity index 98% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/gstmvedemux.h rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/gstmvedemux.h index c8ed20bb8..c8908c297 100644 --- a/project/jni/application/gemrb/src/plugins/MVEPlayer/gstmvedemux.h +++ b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/gstmvedemux.h @@ -121,8 +121,8 @@ struct _GstMveDemuxStream { /*guint8 bpp;*/ /* bytes per pixel */ guint8 *code_map; /*gboolean code_map_avail;*/ - guint8 *back_buf1; - guint8 *back_buf2; + guint16 *back_buf1; + guint16 *back_buf2; guint32 max_block_offset; /*GstBuffer *palette; GstBuffer *buffer;*/ diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/mve.h b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/mve.h rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve.h diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/mve_player.cpp b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve_player.cpp similarity index 97% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/mve_player.cpp rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve_player.cpp index 8c4085362..b8edf7d11 100644 --- a/project/jni/application/gemrb/src/plugins/MVEPlayer/mve_player.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve_player.cpp @@ -311,15 +311,15 @@ void MVEPlayer::segment_video_init(unsigned char version) { if (video_back_buf) free(video_back_buf); unsigned int size = width * height * (truecolour ? 2 : 1); - video_back_buf = (char *)malloc(size * 2); + video_back_buf = (guint16 *)malloc(size * 2); memset(video_back_buf, 0, size * 2); video_data = (GstMveDemuxStream *)malloc(sizeof(GstMveDemuxStream)); video_data->code_map = NULL; video_data->width = width; video_data->height = height; - video_data->back_buf1 = (guint8 *)video_back_buf; - video_data->back_buf2 = (guint8 *)video_back_buf + size; + video_data->back_buf1 = video_back_buf; + video_data->back_buf2 = video_back_buf + size/2; video_data->max_block_offset = (height - 7) * width - 8; } @@ -387,7 +387,7 @@ void MVEPlayer::segment_video_data(unsigned short size) { char *data = buffer + 14; if (flags & MVE_VIDEO_DELTA_FRAME) { - guint8 *temp = video_data->back_buf1; + guint16 *temp = video_data->back_buf1; video_data->back_buf1 = video_data->back_buf2; video_data->back_buf2 = temp; } @@ -404,7 +404,7 @@ void MVEPlayer::segment_video_play() { } else { unsigned int dest_x = (outputwidth - video_data->width) >> 1; unsigned int dest_y = (outputheight - video_data->height) >> 1; - host->showFrame(video_data->back_buf1, video_data->width, video_data->height, 0, 0, video_data->width, video_data->height, dest_x, dest_y); + host->showFrame( (guint8 *) video_data->back_buf1, video_data->width, video_data->height, 0, 0, video_data->width, video_data->height, dest_x, dest_y); } video_rendered_frame = true; diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/mve_player.h b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve_player.h similarity index 98% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/mve_player.h rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve_player.h index d8831a300..77e1fb7b0 100644 --- a/project/jni/application/gemrb/src/plugins/MVEPlayer/mve_player.h +++ b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mve_player.h @@ -39,7 +39,7 @@ protected: struct _GstMveDemuxStream *video_data; unsigned short video_width; unsigned short video_height; - char *video_back_buf; + unsigned short *video_back_buf; bool truecolour; bool video_rendered_frame; unsigned int video_frameskip; diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/mveaudiodec.cpp b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mveaudiodec.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/MVEPlayer/mveaudiodec.cpp rename to project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mveaudiodec.cpp diff --git a/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mvevideodec16.cpp b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mvevideodec16.cpp new file mode 100644 index 000000000..66d158cfc --- /dev/null +++ b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mvevideodec16.cpp @@ -0,0 +1,844 @@ +/* + * Interplay MVE Video Decoder (16 bit) + * Copyright (C) 2003 the ffmpeg project, Mike Melanson + * (C) 2006 Jens Granseuer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * For more information about the Interplay MVE format, visit: + * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt + */ + +#include "gstmvedemux.h" +#include + +#define PIXEL(s) GST_READ_UINT16_LE (s) + +#define CHECK_STREAM(l, n) \ + do { \ + if (G_UNLIKELY (*(l) < (n))) { \ + GST_ERROR ("wanted to read %d bytes from stream, %d available", (n), *(l)); \ + return -1; \ + } \ + *(l) -= (n); \ + } while (0) + +/* copy an 8x8 block from the stream to the frame buffer */ +static int +ipvideo_copy_block (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned short *src, int offset) +{ + int i; + int frame_offset; + + frame_offset = frame - s->back_buf1 + offset; + + if (G_UNLIKELY (frame_offset < 0)) { + GST_ERROR ("frame offset < 0 (%d)", frame_offset); + return -1; + } else if (G_UNLIKELY ((guint32)frame_offset > s->max_block_offset)) { + GST_ERROR ("frame offset above limit (%d > %u)", + frame_offset, s->max_block_offset); + return -1; + } + + for (i = 0; i < 8; ++i) { + memcpy (frame, src, 16); + frame += s->width; + src += s->width; + } + + return 0; +} + +static int +ipvideo_decode_0x2 (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + unsigned char B; + int x, y; + int offset; + + /* copy block from 2 frames ago using a motion vector */ + CHECK_STREAM (len, 1); + B = *(*data)++; + + if (B < 56) { + x = 8 + (B % 7); + y = B / 7; + } else { + x = -14 + ((B - 56) % 29); + y = 8 + ((B - 56) / 29); + } + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, frame + offset, offset); +} + +static int +ipvideo_decode_0x3 (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + unsigned char B; + int x, y; + int offset; + + /* copy 8x8 block from current frame from an up/left block */ + CHECK_STREAM (len, 1); + B = *(*data)++; + + if (B < 56) { + x = -(8 + (B % 7)); + y = -(B / 7); + } else { + x = -(-14 + ((B - 56) % 29)); + y = -(8 + ((B - 56) / 29)); + } + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, frame + offset, offset); +} + +static int +ipvideo_decode_0x4 (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char B; + int offset; + + /* copy a block from the previous frame */ + CHECK_STREAM (len, 1); + B = *(*data)++; + x = -8 + (B & 0x0F); + y = -8 + (B >> 4); + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, frame + + (s->back_buf2 - s->back_buf1) + offset, offset); +} + +static int +ipvideo_decode_0x5 (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + signed char x, y; + int offset; + + /* copy a block from the previous frame using an expanded range */ + CHECK_STREAM (len, 2); + x = (signed char) *(*data)++; + y = (signed char) *(*data)++; + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, frame + + ((unsigned short *) s->back_buf2 - (unsigned short *) s->back_buf1) + + offset, offset); +} + +static int +ipvideo_decode_0x7 (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short P0, P1; + unsigned int flags; + int bitmask; + + /* 2-color encoding */ + CHECK_STREAM (len, 4 + 2); + P0 = PIXEL (*data); + (*data) += 2; + P1 = PIXEL (*data); + (*data) += 2; + + if (!(P0 & 0x8000)) { + + /* need 8 more bytes from the stream */ + CHECK_STREAM (len, 8 - 2); + + for (y = 0; y < 8; ++y) { + flags = *(*data)++; + for (x = 0x01; x <= 0x80; x <<= 1) { + if (flags & x) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + + } else { + P0 &= ~0x8000; + + /* need 2 more bytes from the stream */ + + flags = ((*data)[1] << 8) | (*data)[0]; + (*data) += 2; + bitmask = 0x0001; + for (y = 0; y < 8; y += 2) { + for (x = 0; x < 8; x += 2, bitmask <<= 1) { + if (flags & bitmask) { + *(frame + x) = P1; + *(frame + x + 1) = P1; + *(frame + s->width + x) = P1; + *(frame + s->width + x + 1) = P1; + } else { + *(frame + x) = P0; + *(frame + x + 1) = P0; + *(frame + s->width + x) = P0; + *(frame + s->width + x + 1) = P0; + } + } + frame += s->width * 2; + } + } + + return 0; +} + +static int +ipvideo_decode_0x8 (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short P[8]; + unsigned char B[8]; + unsigned int flags = 0; + unsigned int bitmask = 0; + unsigned short P0 = 0, P1 = 0; + int lower_half = 0; + + /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on + * either top and bottom or left and right halves */ + CHECK_STREAM (len, 6 + 10); + + P[0] = PIXEL (*data); + (*data) += 2; + P[1] = PIXEL (*data); + (*data) += 2; + B[0] = *(*data)++; + B[1] = *(*data)++; + + if (!(P[0] & 0x8000)) { + + /* need 18 more bytes */ + CHECK_STREAM (len, 18 - 10); + + P[2] = PIXEL (*data); + (*data) += 2; + P[3] = PIXEL (*data); + (*data) += 2; + B[2] = *(*data)++; + B[3] = *(*data)++; + P[4] = PIXEL (*data); + (*data) += 2; + P[5] = PIXEL (*data); + (*data) += 2; + B[4] = *(*data)++; + B[5] = *(*data)++; + P[6] = PIXEL (*data); + (*data) += 2; + P[7] = PIXEL (*data); + (*data) += 2; + B[6] = *(*data)++; + B[7] = *(*data)++; + + flags = ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | + ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | + ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | + ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); + bitmask = 0x00000001; + lower_half = 0; /* still on top half */ + + for (y = 0; y < 8; ++y) { + + /* time to reload flags? */ + if (y == 4) { + flags = ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | + ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | + ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | + ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); + bitmask = 0x00000001; + lower_half = 2; + } + + /* get the pixel values ready for this quadrant */ + P0 = P[lower_half + 0]; + P1 = P[lower_half + 1]; + + for (x = 0; x < 8; ++x, bitmask <<= 1) { + if (x == 4) { + P0 = P[lower_half + 4]; + P1 = P[lower_half + 5]; + } + + if (flags & bitmask) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + + } else { + P[0] &= ~0x8000; + + /* need 10 more bytes */ + B[2] = *(*data)++; + B[3] = *(*data)++; + P[2] = PIXEL (*data); + (*data) += 2; + P[3] = PIXEL (*data); + (*data) += 2; + B[4] = *(*data)++; + B[5] = *(*data)++; + B[6] = *(*data)++; + B[7] = *(*data)++; + + if (!(P[2] & 0x8000)) { + /* vertical split; left & right halves are 2-color encoded */ + + flags = + ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | + ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | + ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | + ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); + bitmask = 0x00000001; + + for (y = 0; y < 8; ++y) { + + /* time to reload flags? */ + if (y == 4) { + flags = ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | + ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | + ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | + ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); + bitmask = 0x00000001; + } + + /* get the pixel values ready for this half */ + P0 = P[0]; + P1 = P[1]; + + for (x = 0; x < 8; ++x, bitmask <<= 1) { + if (x == 4) { + P0 = P[2]; + P1 = P[3]; + } + + if (flags & bitmask) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + + } else { + /* horizontal split; top & bottom halves are 2-color encoded */ + + P0 = P[0]; + P1 = P[1]; + + for (y = 0; y < 8; ++y) { + + flags = B[y]; + if (y == 4) { + P0 = P[2] & ~0x8000; + P1 = P[3]; + } + + for (bitmask = 0x01; bitmask <= 0x80; bitmask <<= 1) { + + if (flags & bitmask) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + } + } + + return 0; +} + +static int +ipvideo_decode_0x9 (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short P[4]; + unsigned char B[4]; + unsigned int flags = 0; + int shifter = 0; + unsigned short pix; + + /* 4-color encoding */ + CHECK_STREAM (len, 8 + 4); + + P[0] = PIXEL (*data); + (*data) += 2; + P[1] = PIXEL (*data); + (*data) += 2; + P[2] = PIXEL (*data); + (*data) += 2; + P[3] = PIXEL (*data); + (*data) += 2; + + if (!(P[0] & 0x8000) && !(P[2] & 0x8000)) { + + /* 1 of 4 colors for each pixel, need 16 more bytes */ + CHECK_STREAM (len, 16 - 4); + + for (y = 0; y < 8; ++y) { + /* get the next set of 8 2-bit flags */ + flags = ((*data)[1] << 8) | (*data)[0]; + (*data) += 2; + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { + *frame++ = P[(flags >> shifter) & 0x03]; + } + frame += s->width - 8; + } + + } else if (!(P[0] & 0x8000) && (P[2] & 0x8000)) { + P[2] &= ~0x8000; + + /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ + + B[0] = *(*data)++; + B[1] = *(*data)++; + B[2] = *(*data)++; + B[3] = *(*data)++; + flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; + shifter = 0; + + for (y = 0; y < 8; y += 2) { + for (x = 0; x < 8; x += 2, shifter += 2) { + pix = P[(flags >> shifter) & 0x03]; + *(frame + x) = pix; + *(frame + x + 1) = pix; + *(frame + s->width + x) = pix; + *(frame + s->width + x + 1) = pix; + } + frame += s->width * 2; + } + + } else if ((P[0] & 0x8000) && !(P[2] & 0x8000)) { + P[0] &= ~0x8000; + + /* 1 of 4 colors for each 2x1 block, need 8 more bytes */ + + CHECK_STREAM (len, 8 - 4); + for (y = 0; y < 8; ++y) { + /* time to reload flags? */ + if ((y == 0) || (y == 4)) { + B[0] = *(*data)++; + B[1] = *(*data)++; + B[2] = *(*data)++; + B[3] = *(*data)++; + flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; + shifter = 0; + } + for (x = 0; x < 8; x += 2, shifter += 2) { + pix = P[(flags >> shifter) & 0x03]; + *(frame + x) = pix; + *(frame + x + 1) = pix; + } + frame += s->width; + } + + } else { + P[0] &= ~0x8000; + P[2] &= ~0x8000; + + /* 1 of 4 colors for each 1x2 block, need 8 more bytes */ + CHECK_STREAM (len, 8 - 4); + + for (y = 0; y < 8; y += 2) { + /* time to reload flags? */ + if ((y == 0) || (y == 4)) { + B[0] = *(*data)++; + B[1] = *(*data)++; + B[2] = *(*data)++; + B[3] = *(*data)++; + flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; + shifter = 0; + } + for (x = 0; x < 8; ++x, shifter += 2) { + pix = P[(flags >> shifter) & 0x03]; + *(frame + x) = pix; + *(frame + s->width + x) = pix; + } + frame += s->width * 2; + } + } + + return 0; +} + +static int +ipvideo_decode_0xa (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short P[16]; + unsigned char B[16]; + int flags = 0; + int shifter = 0; + int index; + int split; + int lower_half; + + /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on + * either top and bottom or left and right halves */ + CHECK_STREAM (len, 8 + 24); + + P[0] = PIXEL (*data); + (*data) += 2; + P[1] = PIXEL (*data); + (*data) += 2; + P[2] = PIXEL (*data); + (*data) += 2; + P[3] = PIXEL (*data); + (*data) += 2; + + if (!(P[0] & 0x8000)) { + + /* 4-color encoding for each quadrant; need 40 more bytes */ + CHECK_STREAM (len, 40 - 24); + + B[0] = *(*data)++; + B[1] = *(*data)++; + B[2] = *(*data)++; + B[3] = *(*data)++; + for (y = 4; y < 16; y += 4) { + for (x = y; x < y + 4; ++x) { + P[x] = PIXEL (*data); + (*data) += 2; + } + for (x = y; x < y + 4; ++x) + B[x] = *(*data)++; + } + + for (y = 0; y < 8; ++y) { + + lower_half = (y >= 4) ? 4 : 0; + flags = (B[y + 8] << 8) | B[y]; + + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { + split = (x >= 4) ? 8 : 0; + index = split + lower_half + ((flags >> shifter) & 0x03); + *frame++ = P[index]; + } + + frame += s->width - 8; + } + + } else { + P[0] &= ~0x8000; + + /* 4-color encoding for either left and right or top and bottom + * halves; need 24 more bytes */ + + memcpy (&B[0], *data, 8); + (*data) += 8; + P[4] = PIXEL (*data); + (*data) += 2; + P[5] = PIXEL (*data); + (*data) += 2; + P[6] = PIXEL (*data); + (*data) += 2; + P[7] = PIXEL (*data); + (*data) += 2; + memcpy (&B[8], *data, 8); + (*data) += 8; + + if (!(P[4] & 0x8000)) { + + /* block is divided into left and right halves */ + for (y = 0; y < 8; ++y) { + + flags = (B[y + 8] << 8) | B[y]; + split = 0; + + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { + if (x == 4) + split = 4; + *frame++ = P[split + ((flags >> shifter) & 0x03)]; + } + + frame += s->width - 8; + } + + } else { + P[4] &= ~0x8000; + + /* block is divided into top and bottom halves */ + split = 0; + for (y = 0; y < 8; ++y) { + + flags = (B[y * 2 + 1] << 8) | B[y * 2]; + if (y == 4) + split = 4; + + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) + *frame++ = P[split + ((flags >> shifter) & 0x03)]; + + frame += s->width - 8; + } + } + } + + return 0; +} + +static int +ipvideo_decode_0xb (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + + /* 64-color encoding (each pixel in block is a different color) */ + CHECK_STREAM (len, 128); + + for (y = 0; y < 8; ++y) { + for (x = 0; x < 8; ++x) { + *frame++ = PIXEL (*data); + (*data) += 2; + } + frame += s->width - 8; + } + + return 0; +} + +static int +ipvideo_decode_0xc (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short pix; + + /* 16-color block encoding: each 2x2 block is a different color */ + CHECK_STREAM (len, 32); + + for (y = 0; y < 8; y += 2) { + for (x = 0; x < 8; x += 2) { + pix = PIXEL (*data); + (*data) += 2; + *(frame + x) = pix; + *(frame + x + 1) = pix; + *(frame + s->width + x) = pix; + *(frame + s->width + x + 1) = pix; + } + frame += s->width * 2; + } + + return 0; +} + +static int +ipvideo_decode_0xd (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short P[4]; + unsigned char index = 0; + + /* 4-color block encoding: each 4x4 block is a different color */ + CHECK_STREAM (len, 8); + + P[0] = PIXEL (*data); + (*data) += 2; + P[1] = PIXEL (*data); + (*data) += 2; + P[2] = PIXEL (*data); + (*data) += 2; + P[3] = PIXEL (*data); + (*data) += 2; + + for (y = 0; y < 8; ++y) { + if (y < 4) + index = 0; + else + index = 2; + + for (x = 0; x < 8; ++x) { + if (x == 4) + ++index; + *frame++ = P[index]; + } + frame += s->width - 8; + } + + return 0; +} + +static int +ipvideo_decode_0xe (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short pix; + + /* 1-color encoding: the whole block is 1 solid color */ + CHECK_STREAM (len, 2); + + pix = PIXEL (*data); + (*data) += 2; + + for (y = 0; y < 8; ++y) { + for (x = 0; x < 8; ++x) { + *frame++ = pix; + } + frame += s->width - 8; + } + + return 0; +} + +static int +ipvideo_decode_0xf (const GstMveDemuxStream * s, unsigned short *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned short P[2]; + + /* dithered encoding */ + CHECK_STREAM (len, 4); + + P[0] = PIXEL (*data); + (*data) += 2; + P[1] = PIXEL (*data); + (*data) += 2; + + for (y = 0; y < 8; ++y) { + for (x = 0; x < 4; ++x) { + *frame++ = P[y & 1]; + *frame++ = P[(y & 1) ^ 1]; + } + frame += s->width - 8; + } + + return 0; +} + +int +ipvideo_decode_frame16 (const GstMveDemuxStream * s, const unsigned char *data, + unsigned short len) +{ + int rc = 0; + int x, y, xx, yy; + int index = 0; + unsigned short offset; + unsigned char opcode; + unsigned short *frame; + const unsigned char *data2; + unsigned short len2; + + CHECK_STREAM (&len, 2); + + offset = (data[1] << 8) | data[0]; + data2 = data + offset; + len2 = len - offset + 2; + data += 2; + + frame = s->back_buf1; + + /* decoding is done in 8x8 blocks */ + xx = s->width >> 3; + yy = s->height >> 3; + + for (y = 0; y < yy; ++y) { + for (x = 0; x < xx; ++x) { + /* decoding map contains 4 bits of information per 8x8 block */ + /* bottom nibble first, then top nibble */ + if (index & 1) + opcode = s->code_map[index >> 1] >> 4; + else + opcode = s->code_map[index >> 1] & 0x0F; + ++index; + + /* GST_DEBUG ("block @ (%3d, %3d): encoding 0x%X, data ptr @ %p", + x, y, opcode, data); */ + + switch (opcode) { + case 0x0: + /* copy a block from the previous frame */ + rc = ipvideo_copy_block (s, frame, frame + + (s->back_buf2 - s->back_buf1), 0); + break; + case 0x1: + /* copy block from 2 frames ago; since we switched the back + * buffers we don't actually have to do anything here */ + break; + case 0x2: + rc = ipvideo_decode_0x2 (s, frame, &data2, &len2); + break; + case 0x3: + rc = ipvideo_decode_0x3 (s, frame, &data2, &len2); + break; + case 0x4: + rc = ipvideo_decode_0x4 (s, frame, &data2, &len2); + break; + case 0x5: + rc = ipvideo_decode_0x5 (s, frame, &data, &len); + break; + case 0x6: + /* mystery opcode? skip multiple blocks? */ + GST_WARNING ("encountered unsupported opcode 0x6"); + rc = -1; + break; + case 0x7: + rc = ipvideo_decode_0x7 (s, frame, &data, &len); + break; + case 0x8: + rc = ipvideo_decode_0x8 (s, frame, &data, &len); + break; + case 0x9: + rc = ipvideo_decode_0x9 (s, frame, &data, &len); + break; + case 0xa: + rc = ipvideo_decode_0xa (s, frame, &data, &len); + break; + case 0xb: + rc = ipvideo_decode_0xb (s, frame, &data, &len); + break; + case 0xc: + rc = ipvideo_decode_0xc (s, frame, &data, &len); + break; + case 0xd: + rc = ipvideo_decode_0xd (s, frame, &data, &len); + break; + case 0xe: + rc = ipvideo_decode_0xe (s, frame, &data, &len); + break; + case 0xf: + rc = ipvideo_decode_0xf (s, frame, &data, &len); + break; + } + + if (rc != 0) + return rc; + + frame += 8; + } + frame += 7 * s->width; + } + + return 0; +} diff --git a/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mvevideodec8.cpp b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mvevideodec8.cpp new file mode 100644 index 000000000..5d3820820 --- /dev/null +++ b/project/jni/application/gemrb/gemrb/plugins/MVEPlayer/mvevideodec8.cpp @@ -0,0 +1,797 @@ +/* + * Interplay MVE Video Decoder (8 bit) + * Copyright (C) 2003 the ffmpeg project, Mike Melanson + * (C) 2006 Jens Granseuer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * For more information about the Interplay MVE format, visit: + * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt + */ + +#include "gstmvedemux.h" +#include + +#define CHECK_STREAM(l, n) \ + do { \ + if (G_UNLIKELY (*(l) < (n))) { \ + GST_ERROR ("wanted to read %d bytes from stream, %d available", (n), *(l)); \ + return -1; \ + } \ + *(l) -= (n); \ + } while (0) + + +/* copy an 8x8 block from the stream to the frame buffer */ +static int +ipvideo_copy_block (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char *src, int offset) +{ + int i; + long frame_offset; + + frame_offset = frame - (guint8 *) s->back_buf1 + offset; + + if (G_UNLIKELY (frame_offset < 0)) { + GST_ERROR ("frame offset < 0 (%ld)", frame_offset); + return -1; + } else if (G_UNLIKELY ((guint32)frame_offset > s->max_block_offset)) { + GST_ERROR ("frame offset above limit (%ld > %u)", + frame_offset, s->max_block_offset); + return -1; + } + + for (i = 0; i < 8; ++i) { + memcpy (frame, src, 8); + frame += s->width; + src += s->width; + } + + return 0; +} + +static int +ipvideo_decode_0x2 (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + unsigned char B; + int x, y; + int offset; + + /* copy block from 2 frames ago using a motion vector */ + CHECK_STREAM (len, 1); + B = *(*data)++; + + if (B < 56) { + x = 8 + (B % 7); + y = B / 7; + } else { + x = -14 + ((B - 56) % 29); + y = 8 + ((B - 56) / 29); + } + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, frame + offset, offset); +} + +static int +ipvideo_decode_0x3 (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + unsigned char B; + int x, y; + int offset; + + /* copy 8x8 block from current frame from an up/left block */ + CHECK_STREAM (len, 1); + B = *(*data)++; + + if (B < 56) { + x = -(8 + (B % 7)); + y = -(B / 7); + } else { + x = -(-14 + ((B - 56) % 29)); + y = -(8 + ((B - 56) / 29)); + } + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, frame + offset, offset); +} + +static int +ipvideo_decode_0x4 (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + unsigned char B; + int x, y; + int offset; + + /* copy a block from the previous frame */ + CHECK_STREAM (len, 1); + B = *(*data)++; + x = -8 + (B & 0x0F); + y = -8 + (B >> 4); + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, + frame + ((guint8 *) s->back_buf2 - (guint8 *) s->back_buf1) + offset, offset); +} + +static int +ipvideo_decode_0x5 (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + signed char x, y; + int offset; + + /* copy a block from the previous frame using an expanded range */ + CHECK_STREAM (len, 2); + + x = (signed char) *(*data)++; + y = (signed char) *(*data)++; + offset = y * s->width + x; + + return ipvideo_copy_block (s, frame, + frame + ((guint8 *) s->back_buf2 - (guint8 *) s->back_buf1) + offset, offset); +} + +static int +ipvideo_decode_0x7 (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char P0, P1; + unsigned int flags; + int bitmask; + + /* 2-color encoding */ + CHECK_STREAM (len, 2 + 2); + + P0 = *(*data)++; + P1 = *(*data)++; + + if (P0 <= P1) { + + /* need 8 more bytes from the stream */ + CHECK_STREAM (len, 8 - 2); + + for (y = 0; y < 8; ++y) { + flags = *(*data)++; + for (x = 0x01; x <= 0x80; x <<= 1) { + if (flags & x) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + + } else { + + /* need 2 more bytes from the stream */ + flags = ((*data)[1] << 8) | (*data)[0]; + (*data) += 2; + bitmask = 0x0001; + for (y = 0; y < 8; y += 2) { + for (x = 0; x < 8; x += 2, bitmask <<= 1) { + if (flags & bitmask) { + *(frame + x) = P1; + *(frame + x + 1) = P1; + *(frame + s->width + x) = P1; + *(frame + s->width + x + 1) = P1; + } else { + *(frame + x) = P0; + *(frame + x + 1) = P0; + *(frame + s->width + x) = P0; + *(frame + s->width + x + 1) = P0; + } + } + frame += s->width * 2; + } + } + + return 0; +} + +static int +ipvideo_decode_0x8 (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char P[8]; + unsigned char B[8]; + unsigned int flags = 0; + unsigned int bitmask = 0; + unsigned char P0 = 0, P1 = 0; + int lower_half = 0; + + /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on + * either top and bottom or left and right halves */ + CHECK_STREAM (len, 4 + 8); + + P[0] = (*data)[0]; + P[1] = (*data)[1]; + B[0] = (*data)[2]; + B[1] = (*data)[3]; + (*data) += 4; + + if (P[0] <= P[1]) { + + /* need 12 more bytes */ + CHECK_STREAM (len, 12 - 8); + + P[2] = (*data)[0]; + P[3] = (*data)[1]; + B[2] = (*data)[2]; + B[3] = (*data)[3]; + P[4] = (*data)[4]; + P[5] = (*data)[5]; + B[4] = (*data)[6]; + B[5] = (*data)[7]; + P[6] = (*data)[8]; + P[7] = (*data)[9]; + B[6] = (*data)[10]; + B[7] = (*data)[11]; + (*data) += 12; + + flags = + ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | + ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | + ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | + ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); + bitmask = 0x00000001; + lower_half = 0; /* still on top half */ + + for (y = 0; y < 8; ++y) { + + /* time to reload flags? */ + if (y == 4) { + flags = + ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | + ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | + ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | + ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); + bitmask = 0x00000001; + lower_half = 2; + } + + /* get the pixel values ready for this quadrant */ + P0 = P[lower_half + 0]; + P1 = P[lower_half + 1]; + + for (x = 0; x < 8; ++x, bitmask <<= 1) { + if (x == 4) { + P0 = P[lower_half + 4]; + P1 = P[lower_half + 5]; + } + + if (flags & bitmask) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + + } else { + + /* need 8 more bytes */ + B[2] = (*data)[0]; + B[3] = (*data)[1]; + P[2] = (*data)[2]; + P[3] = (*data)[3]; + B[4] = (*data)[4]; + B[5] = (*data)[5]; + B[6] = (*data)[6]; + B[7] = (*data)[7]; + (*data) += 8; + + if (P[2] <= P[3]) { + + /* vertical split; left & right halves are 2-color encoded */ + + flags = ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | + ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | + ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | + ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); + bitmask = 0x00000001; + + for (y = 0; y < 8; ++y) { + + /* time to reload flags? */ + if (y == 4) { + flags = ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | + ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | + ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | + ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); + bitmask = 0x00000001; + } + + /* get the pixel values ready for this half */ + P0 = P[0]; + P1 = P[1]; + + for (x = 0; x < 8; ++x, bitmask <<= 1) { + if (x == 4) { + P0 = P[2]; + P1 = P[3]; + } + + if (flags & bitmask) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + + } else { + + /* horizontal split; top & bottom halves are 2-color encoded */ + + P0 = P[0]; + P1 = P[1]; + + for (y = 0; y < 8; ++y) { + + flags = B[y]; + if (y == 4) { + P0 = P[2]; + P1 = P[3]; + } + + for (bitmask = 0x01; bitmask <= 0x80; bitmask <<= 1) { + + if (flags & bitmask) + *frame++ = P1; + else + *frame++ = P0; + } + frame += s->width - 8; + } + } + } + + return 0; +} + +static int +ipvideo_decode_0x9 (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char P[4]; + unsigned char B[4]; + unsigned long flags = 0; + int shifter = 0; + unsigned char pix; + + /* 4-color encoding */ + CHECK_STREAM (len, 4 + 4); + + P[0] = (*data)[0]; + P[1] = (*data)[1]; + P[2] = (*data)[2]; + P[3] = (*data)[3]; + (*data) += 4; + + if ((P[0] <= P[1]) && (P[2] <= P[3])) { + + /* 1 of 4 colors for each pixel, need 16 more bytes */ + CHECK_STREAM (len, 16 - 4); + + for (y = 0; y < 8; ++y) { + /* get the next set of 8 2-bit flags */ + flags = ((*data)[1] << 8) | (*data)[0]; + (*data) += 2; + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { + *frame++ = P[(flags >> shifter) & 0x03]; + } + frame += s->width - 8; + } + + } else if ((P[0] <= P[1]) && (P[2] > P[3])) { + + /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ + B[0] = (*data)[0]; + B[1] = (*data)[1]; + B[2] = (*data)[2]; + B[3] = (*data)[3]; + (*data) += 4; + flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; + shifter = 0; + + for (y = 0; y < 8; y += 2) { + for (x = 0; x < 8; x += 2, shifter += 2) { + pix = P[(flags >> shifter) & 0x03]; + *(frame + x) = pix; + *(frame + x + 1) = pix; + *(frame + s->width + x) = pix; + *(frame + s->width + x + 1) = pix; + } + frame += s->width * 2; + } + + } else if ((P[0] > P[1]) && (P[2] <= P[3])) { + + /* 1 of 4 colors for each 2x1 block, need 8 more bytes */ + CHECK_STREAM (len, 8 - 4); + + for (y = 0; y < 8; ++y) { + /* time to reload flags? */ + if ((y == 0) || (y == 4)) { + B[0] = (*data)[0]; + B[1] = (*data)[1]; + B[2] = (*data)[2]; + B[3] = (*data)[3]; + (*data) += 4; + flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; + shifter = 0; + } + for (x = 0; x < 8; x += 2, shifter += 2) { + pix = P[(flags >> shifter) & 0x03]; + *(frame + x) = pix; + *(frame + x + 1) = pix; + } + frame += s->width; + } + + } else { + + /* 1 of 4 colors for each 1x2 block, need 8 more bytes */ + CHECK_STREAM (len, 8 - 4); + + for (y = 0; y < 8; y += 2) { + /* time to reload flags? */ + if ((y == 0) || (y == 4)) { + B[0] = (*data)[0]; + B[1] = (*data)[1]; + B[2] = (*data)[2]; + B[3] = (*data)[3]; + (*data) += 4; + flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; + shifter = 0; + } + for (x = 0; x < 8; ++x, shifter += 2) { + pix = P[(flags >> shifter) & 0x03]; + *(frame + x) = pix; + *(frame + s->width + x) = pix; + } + frame += s->width * 2; + } + } + + return 0; +} + +static int +ipvideo_decode_0xa (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char P[16]; + unsigned char B[16]; + int flags = 0; + int shifter = 0; + int index; + int split; + int lower_half; + + /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on + * either top and bottom or left and right halves */ + CHECK_STREAM (len, 8 + 16); + + P[0] = (*data)[0]; + P[1] = (*data)[1]; + P[2] = (*data)[2]; + P[3] = (*data)[3]; + B[0] = (*data)[4]; + B[1] = (*data)[5]; + B[2] = (*data)[6]; + B[3] = (*data)[7]; + (*data) += 8; + + if (P[0] <= P[1]) { + + /* 4-color encoding for each quadrant; need 24 more bytes */ + CHECK_STREAM (len, 24 - 16); + + for (y = 4; y < 16; y += 4) { + for (x = y; x < y + 4; ++x) + P[x] = *(*data)++; + for (x = y; x < y + 4; ++x) + B[x] = *(*data)++; + } + + for (y = 0; y < 8; ++y) { + + lower_half = (y >= 4) ? 4 : 0; + flags = (B[y + 8] << 8) | B[y]; + + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { + split = (x >= 4) ? 8 : 0; + index = split + lower_half + ((flags >> shifter) & 0x03); + *frame++ = P[index]; + } + + frame += s->width - 8; + } + + } else { + + /* 4-color encoding for either left and right or top and bottom + * halves; need 16 more bytes */ + + B[4] = (*data)[0]; + B[5] = (*data)[1]; + B[6] = (*data)[2]; + B[7] = (*data)[3]; + P[4] = (*data)[4]; + P[5] = (*data)[5]; + P[6] = (*data)[6]; + P[7] = (*data)[7]; + (*data) += 8; + memcpy (&B[8], *data, 8); + (*data) += 8; + + if (P[4] <= P[5]) { + + /* block is divided into left and right halves */ + for (y = 0; y < 8; ++y) { + + flags = (B[y + 8] << 8) | B[y]; + split = 0; + + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { + if (x == 4) + split = 4; + *frame++ = P[split + ((flags >> shifter) & 0x03)]; + } + + frame += s->width - 8; + } + + } else { + + /* block is divided into top and bottom halves */ + split = 0; + for (y = 0; y < 8; ++y) { + + flags = (B[y * 2 + 1] << 8) | B[y * 2]; + if (y == 4) + split = 4; + + for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) + *frame++ = P[split + ((flags >> shifter) & 0x03)]; + + frame += s->width - 8; + } + } + } + + return 0; +} + +static int +ipvideo_decode_0xb (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int y; + + /* 64-color encoding (each pixel in block is a different color) */ + CHECK_STREAM (len, 64); + + for (y = 0; y < 8; ++y) { + memcpy (frame, *data, 8); + frame += s->width; + (*data) += 8; + } + + return 0; +} + +static int +ipvideo_decode_0xc (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char pix; + + /* 16-color block encoding: each 2x2 block is a different color */ + CHECK_STREAM (len, 16); + + for (y = 0; y < 8; y += 2) { + for (x = 0; x < 8; x += 2) { + pix = *(*data)++; + *(frame + x) = pix; + *(frame + x + 1) = pix; + *(frame + s->width + x) = pix; + *(frame + s->width + x + 1) = pix; + } + frame += s->width * 2; + } + + return 0; +} + +static int +ipvideo_decode_0xd (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char P[4]; + unsigned char index = 0; + + /* 4-color block encoding: each 4x4 block is a different color */ + CHECK_STREAM (len, 4); + + P[0] = (*data)[0]; + P[1] = (*data)[1]; + P[2] = (*data)[2]; + P[3] = (*data)[3]; + (*data) += 4; + + for (y = 0; y < 8; ++y) { + if (y < 4) + index = 0; + else + index = 2; + + for (x = 0; x < 8; ++x) { + if (x == 4) + ++index; + *frame++ = P[index]; + } + frame += s->width - 8; + } + + return 0; +} + +static int +ipvideo_decode_0xe (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int y; + unsigned char pix; + + /* 1-color encoding: the whole block is 1 solid color */ + CHECK_STREAM (len, 1); + pix = *(*data)++; + + for (y = 0; y < 8; ++y) { + memset (frame, pix, 8); + frame += s->width; + } + + return 0; +} + +static int +ipvideo_decode_0xf (const GstMveDemuxStream * s, unsigned char *frame, + const unsigned char **data, unsigned short *len) +{ + int x, y; + unsigned char P[2]; + + /* dithered encoding */ + CHECK_STREAM (len, 2); + + P[0] = *(*data)++; + P[1] = *(*data)++; + + for (y = 0; y < 8; ++y) { + for (x = 0; x < 4; ++x) { + *frame++ = P[y & 1]; + *frame++ = P[(y & 1) ^ 1]; + } + frame += s->width - 8; + } + + return 0; +} + +int +ipvideo_decode_frame8 (const GstMveDemuxStream * s, const unsigned char *data, + unsigned short len) +{ + int rc = 0; + int x, y, xx, yy; + int index = 0; + unsigned char opcode; + unsigned char *frame; + + frame = (guint8 *) s->back_buf1; + + /* decoding is done in 8x8 blocks */ + xx = s->width >> 3; + yy = s->height >> 3; + + for (y = 0; y < yy; ++y) { + for (x = 0; x < xx; ++x) { + /* decoding map contains 4 bits of information per 8x8 block */ + /* bottom nibble first, then top nibble */ + if (index & 1) + opcode = s->code_map[index >> 1] >> 4; + else + opcode = s->code_map[index >> 1] & 0x0F; + ++index; + + switch (opcode) { + case 0x00: + /* copy a block from the previous frame */ + rc = ipvideo_copy_block (s, frame, + frame + ((guint8 *) s->back_buf2 - (guint8 *) s->back_buf1), 0); + break; + case 0x01: + /* copy block from 2 frames ago; since we switched the back + * buffers we don't actually have to do anything here */ + break; + case 0x02: + rc = ipvideo_decode_0x2 (s, frame, &data, &len); + break; + case 0x03: + rc = ipvideo_decode_0x3 (s, frame, &data, &len); + break; + case 0x04: + rc = ipvideo_decode_0x4 (s, frame, &data, &len); + break; + case 0x05: + rc = ipvideo_decode_0x5 (s, frame, &data, &len); + break; + case 0x06: + /* mystery opcode? skip multiple blocks? */ + GST_WARNING ("encountered unsupported opcode 0x6"); + rc = -1; + break; + case 0x07: + rc = ipvideo_decode_0x7 (s, frame, &data, &len); + break; + case 0x08: + rc = ipvideo_decode_0x8 (s, frame, &data, &len); + break; + case 0x09: + rc = ipvideo_decode_0x9 (s, frame, &data, &len); + break; + case 0x0a: + rc = ipvideo_decode_0xa (s, frame, &data, &len); + break; + case 0x0b: + rc = ipvideo_decode_0xb (s, frame, &data, &len); + break; + case 0x0c: + rc = ipvideo_decode_0xc (s, frame, &data, &len); + break; + case 0x0d: + rc = ipvideo_decode_0xd (s, frame, &data, &len); + break; + case 0x0e: + rc = ipvideo_decode_0xe (s, frame, &data, &len); + break; + case 0x0f: + rc = ipvideo_decode_0xf (s, frame, &data, &len); + break; + } + + if (rc != 0) + return rc; + + frame += 8; + } + frame += 7 * s->width; + } + + return 0; +} diff --git a/project/jni/application/gemrb/src/plugins/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/NullSound/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/NullSound/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/NullSound/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/NullSound/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/NullSound/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/NullSound/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/NullSound/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/NullSound/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/NullSound/NullSound.cpp b/project/jni/application/gemrb/gemrb/plugins/NullSound/NullSound.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/NullSound/NullSound.cpp rename to project/jni/application/gemrb/gemrb/plugins/NullSound/NullSound.cpp diff --git a/project/jni/application/gemrb/src/plugins/NullSound/NullSound.h b/project/jni/application/gemrb/gemrb/plugins/NullSound/NullSound.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/NullSound/NullSound.h rename to project/jni/application/gemrb/gemrb/plugins/NullSound/NullSound.h diff --git a/project/jni/application/gemrb/src/plugins/OGGReader/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/OGGReader/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/OGGReader/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/OGGReader/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/OGGReader/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/OGGReader/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/OGGReader/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/OGGReader/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/OGGReader/OGGReader.cpp b/project/jni/application/gemrb/gemrb/plugins/OGGReader/OGGReader.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/OGGReader/OGGReader.cpp rename to project/jni/application/gemrb/gemrb/plugins/OGGReader/OGGReader.cpp diff --git a/project/jni/application/gemrb/src/plugins/OGGReader/OGGReader.h b/project/jni/application/gemrb/gemrb/plugins/OGGReader/OGGReader.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/OGGReader/OGGReader.h rename to project/jni/application/gemrb/gemrb/plugins/OGGReader/OGGReader.h diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/AmbientMgrAL.cpp b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/AmbientMgrAL.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/AmbientMgrAL.cpp rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/AmbientMgrAL.cpp diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/AmbientMgrAL.h b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/AmbientMgrAL.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/AmbientMgrAL.h rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/AmbientMgrAL.h diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/OpenALAudio.cpp b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/OpenALAudio.cpp similarity index 99% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/OpenALAudio.cpp rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/OpenALAudio.cpp index d85e13635..9a4440ebb 100644 --- a/project/jni/application/gemrb/src/plugins/OpenALAudio/OpenALAudio.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/OpenALAudio.cpp @@ -505,6 +505,7 @@ bool OpenALAudioDriver::Stop() SDL_mutexV( musicMutex ); return true; } + bool OpenALAudioDriver::Pause() { SDL_mutexP( musicMutex ); @@ -512,21 +513,20 @@ bool OpenALAudioDriver::Pause() SDL_mutexV( musicMutex ); return false; } - // pause Music alSourcePause(MusicSource); checkALError("Unable to pause music source", "WARNING"); MusicPlaying = false; SDL_mutexV( musicMutex ); ((AmbientMgrAL*) ambim)->deactivate(); -#ifdef ANDROID +#ifdef ANDROID al_android_pause_playback(); //call AudioTrack.pause() from JNI -#endif +#endif return true; } bool OpenALAudioDriver::Resume() { -#ifdef ANDROID +#ifdef ANDROID al_android_resume_playback(); //call AudioTrack.play() from JNI #endif SDL_mutexP( musicMutex ); @@ -534,12 +534,11 @@ bool OpenALAudioDriver::Resume() SDL_mutexV( musicMutex ); return false; } - // resume Music alSourcePlay(MusicSource); checkALError("Unable to resume music source", "WARNING"); MusicPlaying = true; SDL_mutexV( musicMutex ); - ((AmbientMgrAL*) ambim)->activate(); + ((AmbientMgrAL*) ambim)->activate(); return true; } diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/OpenALAudio.h b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/OpenALAudio.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/OpenALAudio.h rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/OpenALAudio.h diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/StackLock.cpp b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/StackLock.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/StackLock.cpp rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/StackLock.cpp diff --git a/project/jni/application/gemrb/src/plugins/OpenALAudio/StackLock.h b/project/jni/application/gemrb/gemrb/plugins/OpenALAudio/StackLock.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/OpenALAudio/StackLock.h rename to project/jni/application/gemrb/gemrb/plugins/OpenALAudio/StackLock.h diff --git a/project/jni/application/gemrb/src/plugins/PLTImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/PLTImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/PLTImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/PLTImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/PLTImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/PLTImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/PLTImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/PLTImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/PLTImporter/PLTImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/PLTImporter/PLTImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/PLTImporter/PLTImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/PLTImporter/PLTImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/PLTImporter/PLTImporter.h b/project/jni/application/gemrb/gemrb/plugins/PLTImporter/PLTImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/PLTImporter/PLTImporter.h rename to project/jni/application/gemrb/gemrb/plugins/PLTImporter/PLTImporter.h diff --git a/project/jni/application/gemrb/src/plugins/PNGImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/PNGImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/PNGImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/PNGImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/PNGImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/PNGImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/PNGImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/PNGImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/PNGImporter/PNGImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/PNGImporter/PNGImporter.cpp similarity index 99% rename from project/jni/application/gemrb/src/plugins/PNGImporter/PNGImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/PNGImporter/PNGImporter.cpp index c4dba11fe..30afe7481 100644 --- a/project/jni/application/gemrb/src/plugins/PNGImporter/PNGImporter.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/PNGImporter/PNGImporter.cpp @@ -33,7 +33,7 @@ static void DataStream_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - voidp read_io_ptr = png_get_io_ptr(png_ptr); + void *read_io_ptr = png_get_io_ptr(png_ptr); DataStream* str = reinterpret_cast(read_io_ptr); str->Read(data, length); } diff --git a/project/jni/application/gemrb/src/plugins/PNGImporter/PNGImporter.h b/project/jni/application/gemrb/gemrb/plugins/PNGImporter/PNGImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/PNGImporter/PNGImporter.h rename to project/jni/application/gemrb/gemrb/plugins/PNGImporter/PNGImporter.h diff --git a/project/jni/application/gemrb/src/plugins/PROImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/PROImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/PROImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/PROImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/PROImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/PROImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/PROImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/PROImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/PROImporter/PROImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/PROImporter/PROImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/PROImporter/PROImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/PROImporter/PROImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/PROImporter/PROImporter.h b/project/jni/application/gemrb/gemrb/plugins/PROImporter/PROImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/PROImporter/PROImporter.h rename to project/jni/application/gemrb/gemrb/plugins/PROImporter/PROImporter.h diff --git a/project/jni/application/gemrb/src/plugins/PSTOpcodes/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/PSTOpcodes/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/PSTOpcodes/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/PSTOpcodes/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/PSTOpcodes/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/PSTOpcodes/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/PSTOpcodes/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/PSTOpcodes/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/PSTOpcodes/PSTOpcodes.cpp b/project/jni/application/gemrb/gemrb/plugins/PSTOpcodes/PSTOpcodes.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/PSTOpcodes/PSTOpcodes.cpp rename to project/jni/application/gemrb/gemrb/plugins/PSTOpcodes/PSTOpcodes.cpp diff --git a/project/jni/application/gemrb/src/plugins/SDLAudio/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/SDLAudio/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLAudio/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/SDLAudio/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/SDLAudio/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/SDLAudio/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLAudio/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/SDLAudio/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/SDLAudio/SDLAudio.cpp b/project/jni/application/gemrb/gemrb/plugins/SDLAudio/SDLAudio.cpp similarity index 99% rename from project/jni/application/gemrb/src/plugins/SDLAudio/SDLAudio.cpp rename to project/jni/application/gemrb/gemrb/plugins/SDLAudio/SDLAudio.cpp index b5ae6216b..d3075529b 100644 --- a/project/jni/application/gemrb/src/plugins/SDLAudio/SDLAudio.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/SDLAudio/SDLAudio.cpp @@ -94,7 +94,7 @@ void SDLAudio::music_callback(void *udata, unsigned short *stream, int len) { printMessage("SDLAudio", "Playing Next Music\n", WHITE ); core->GetMusicMgr()->PlayNext(); - stream = stream + (cnt * 2); + stream = stream + cnt; len = len - (cnt * 2); if (!driver->MusicPlaying) { diff --git a/project/jni/application/gemrb/src/plugins/SDLAudio/SDLAudio.h b/project/jni/application/gemrb/gemrb/plugins/SDLAudio/SDLAudio.h similarity index 95% rename from project/jni/application/gemrb/src/plugins/SDLAudio/SDLAudio.h rename to project/jni/application/gemrb/gemrb/plugins/SDLAudio/SDLAudio.h index 0e3398bd2..b31f45ec7 100644 --- a/project/jni/application/gemrb/src/plugins/SDLAudio/SDLAudio.h +++ b/project/jni/application/gemrb/gemrb/plugins/SDLAudio/SDLAudio.h @@ -39,8 +39,8 @@ public: int CreateStream(Holder); bool Play(); bool Stop(); - bool Pause(){/*not implemented*/ return true; } - bool Resume(){/*not implemented*/ return true; } + bool Pause() { return true; } /*not implemented*/ + bool Resume() { return true; } /*not implemented*/ bool CanPlay(); bool IsSpeaking(); void ResetMusics(); diff --git a/project/jni/application/gemrb/src/plugins/SDLVideo/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/SDLVideo/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLVideo/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/SDLVideo/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/SDLVideo/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/SDLVideo/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLVideo/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/SDLVideo/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/SDLVideo/SDLVideo.cpp b/project/jni/application/gemrb/gemrb/plugins/SDLVideo/SDLVideo.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLVideo/SDLVideo.cpp rename to project/jni/application/gemrb/gemrb/plugins/SDLVideo/SDLVideo.cpp diff --git a/project/jni/application/gemrb/src/plugins/SDLVideo/SDLVideo.h b/project/jni/application/gemrb/gemrb/plugins/SDLVideo/SDLVideo.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLVideo/SDLVideo.h rename to project/jni/application/gemrb/gemrb/plugins/SDLVideo/SDLVideo.h diff --git a/project/jni/application/gemrb/src/plugins/SDLVideo/SDLVideoDriver.inl b/project/jni/application/gemrb/gemrb/plugins/SDLVideo/SDLVideoDriver.inl similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLVideo/SDLVideoDriver.inl rename to project/jni/application/gemrb/gemrb/plugins/SDLVideo/SDLVideoDriver.inl diff --git a/project/jni/application/gemrb/src/plugins/SDLVideo/TileRenderer.inl b/project/jni/application/gemrb/gemrb/plugins/SDLVideo/TileRenderer.inl similarity index 100% rename from project/jni/application/gemrb/src/plugins/SDLVideo/TileRenderer.inl rename to project/jni/application/gemrb/gemrb/plugins/SDLVideo/TileRenderer.inl diff --git a/project/jni/application/gemrb/src/plugins/SPLImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/SPLImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/SPLImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/SPLImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/SPLImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/SPLImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/SPLImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/SPLImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/SPLImporter/SPLImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/SPLImporter/SPLImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/SPLImporter/SPLImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/SPLImporter/SPLImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/SPLImporter/SPLImporter.h b/project/jni/application/gemrb/gemrb/plugins/SPLImporter/SPLImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/SPLImporter/SPLImporter.h rename to project/jni/application/gemrb/gemrb/plugins/SPLImporter/SPLImporter.h diff --git a/project/jni/application/gemrb/src/plugins/STOImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/STOImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/STOImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/STOImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/STOImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/STOImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/STOImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/STOImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/STOImporter/STOImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/STOImporter/STOImporter.cpp similarity index 97% rename from project/jni/application/gemrb/src/plugins/STOImporter/STOImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/STOImporter/STOImporter.cpp index b4543a086..b6f086b06 100644 --- a/project/jni/application/gemrb/src/plugins/STOImporter/STOImporter.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/STOImporter/STOImporter.cpp @@ -129,7 +129,7 @@ Store* STOImporter::GetStore(Store *s) str->Seek( s->ItemsOffset, GEM_STREAM_START ); for (i = 0; i < s->ItemsCount; i++) { - STOItem *item = s->items[i]; + STOItem *item = s->items[i]; GetItem(item); //it is important to handle this field as signed if (item->InfiniteSupply>0) { @@ -160,14 +160,9 @@ void STOImporter::GetItem(STOItem *it) { CREItem *itm = core->ReadItem(str); memcpy(it, itm, sizeof(CREItem) ); -/* - str->ReadResRef( it->ItemResRef ); - str->ReadWord( &it->PurchasedAmount ); - for (int i=0;iReadWord( it->Usages+i ); - } - str->ReadDword( &it->Flags ); -*/ + //core allocates CREItem!!! + delete itm; + str->ReadDword( &it->AmountInStock ); //if there was no item on stock, how this could be 0 //we hack-fix this here so it won't cause trouble diff --git a/project/jni/application/gemrb/src/plugins/STOImporter/STOImporter.h b/project/jni/application/gemrb/gemrb/plugins/STOImporter/STOImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/STOImporter/STOImporter.h rename to project/jni/application/gemrb/gemrb/plugins/STOImporter/STOImporter.h diff --git a/project/jni/application/gemrb/src/plugins/TISImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/TISImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/TISImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/TISImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/TISImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/TISImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/TISImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/TISImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/TISImporter/TISImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/TISImporter/TISImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/TISImporter/TISImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/TISImporter/TISImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/TISImporter/TISImporter.h b/project/jni/application/gemrb/gemrb/plugins/TISImporter/TISImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/TISImporter/TISImporter.h rename to project/jni/application/gemrb/gemrb/plugins/TISImporter/TISImporter.h diff --git a/project/jni/application/gemrb/src/plugins/TLKImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/TLKImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/TLKImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/TLKImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/TLKImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/TLKImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/TLKImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/TLKImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/TLKImporter/TLKImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/TLKImporter/TLKImporter.cpp similarity index 83% rename from project/jni/application/gemrb/src/plugins/TLKImporter/TLKImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/TLKImporter/TLKImporter.cpp index fdaee2b56..ed5732fee 100644 --- a/project/jni/application/gemrb/src/plugins/TLKImporter/TLKImporter.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/TLKImporter/TLKImporter.cpp @@ -249,44 +249,6 @@ int TLKImporter::BuiltinToken(char* Token, char* dest) Decoded = GetString( RaceStrRef(-1), 0); goto exit_function; } -/* - if (!strcmp( Token, "SIRMAAM" )) { - Decoded = GetString( GenderStrRef(-1,27473,27475), 0); - goto exit_function; - } - if (!strcmp( Token, "GIRLBOY" )) { - Decoded = GetString( GenderStrRef(-1,27477,27476), 0); - goto exit_function; - } - if (!strcmp( Token, "BROTHERSISTER" )) { - Decoded = GetString( GenderStrRef(-1,27478,27479), 0); - goto exit_function; - } - if (!strcmp( Token, "LADYLORD" )) { - Decoded = GetString( GenderStrRef(-1,27481,27480), 0); - goto exit_function; - } - if (!strcmp( Token, "MALEFEMALE" )) { - Decoded = GetString( GenderStrRef(-1,27482,27483), 0); - goto exit_function; - } - if (!strcmp( Token, "HESHE" )) { - Decoded = GetString( GenderStrRef(-1,27484,27485), 0); - goto exit_function; - } - if (!strcmp( Token, "HISHER" )) { - Decoded = GetString( GenderStrRef(-1,27486,27487), 0); - goto exit_function; - } - if (!strcmp( Token, "HIMHER" )) { - Decoded = GetString( GenderStrRef(-1,27488,27487), 0); - goto exit_function; - } - if (!strcmp( Token, "MANWOMAN" )) { - Decoded = GetString( GenderStrRef(-1,27489,27490), 0); - goto exit_function; - } -*/ if (!strncmp( Token, "PLAYER",6 )) { Decoded = CharName(Token[6]-'1'); goto exit_function; @@ -304,44 +266,6 @@ int TLKImporter::BuiltinToken(char* Token, char* dest) Decoded = GetString( RaceStrRef(0), 0); goto exit_function; } -/* - if (!strcmp( Token, "PRO_SIRMAAM" )) { - Decoded = GetString( GenderStrRef(0,27473,27475), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_GIRLBOY" )) { - Decoded = GetString( GenderStrRef(0,27477,27476), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_BROTHERSISTER" )) { - Decoded = GetString( GenderStrRef(0,27478,27479), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_LADYLORD" )) { - Decoded = GetString( GenderStrRef(0,27481,27480), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_MALEFEMALE" )) { - Decoded = GetString( GenderStrRef(0,27482,27483), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_HESHE" )) { - Decoded = GetString( GenderStrRef(0,27484,27485), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_HISHER" )) { - Decoded = GetString( GenderStrRef(0,27486,27487), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_HIMHER" )) { - Decoded = GetString( GenderStrRef(0,27488,27487), 0); - goto exit_function; - } - if (!strcmp( Token, "PRO_MANWOMAN" )) { - Decoded = GetString( GenderStrRef(0,27489,27490), 0); - goto exit_function; - } -*/ if (!strcmp( Token, "MAGESCHOOL" )) { ieDword row = 0; //default value is 0 (generalist) //this is subject to change, the row number in magesch.2da diff --git a/project/jni/application/gemrb/src/plugins/TLKImporter/TLKImporter.h b/project/jni/application/gemrb/gemrb/plugins/TLKImporter/TLKImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/TLKImporter/TLKImporter.h rename to project/jni/application/gemrb/gemrb/plugins/TLKImporter/TLKImporter.h diff --git a/project/jni/application/gemrb/src/plugins/TLKImporter/TlkOverride.cpp b/project/jni/application/gemrb/gemrb/plugins/TLKImporter/TlkOverride.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/TLKImporter/TlkOverride.cpp rename to project/jni/application/gemrb/gemrb/plugins/TLKImporter/TlkOverride.cpp diff --git a/project/jni/application/gemrb/src/plugins/TLKImporter/TlkOverride.h b/project/jni/application/gemrb/gemrb/plugins/TLKImporter/TlkOverride.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/TLKImporter/TlkOverride.h rename to project/jni/application/gemrb/gemrb/plugins/TLKImporter/TlkOverride.h diff --git a/project/jni/application/gemrb/src/plugins/WAVReader/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/WAVReader/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/WAVReader/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/WAVReader/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/WAVReader/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/WAVReader/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/WAVReader/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/WAVReader/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/WAVReader/WAVReader.cpp b/project/jni/application/gemrb/gemrb/plugins/WAVReader/WAVReader.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/WAVReader/WAVReader.cpp rename to project/jni/application/gemrb/gemrb/plugins/WAVReader/WAVReader.cpp diff --git a/project/jni/application/gemrb/src/plugins/WAVReader/WAVReader.h b/project/jni/application/gemrb/gemrb/plugins/WAVReader/WAVReader.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/WAVReader/WAVReader.h rename to project/jni/application/gemrb/gemrb/plugins/WAVReader/WAVReader.h diff --git a/project/jni/application/gemrb/src/plugins/WEDImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/WEDImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/WEDImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/WEDImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/WEDImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/WEDImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/WEDImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/WEDImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/WEDImporter/WEDImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/WEDImporter/WEDImporter.cpp similarity index 98% rename from project/jni/application/gemrb/src/plugins/WEDImporter/WEDImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/WEDImporter/WEDImporter.cpp index 1526d51d5..802937dcc 100644 --- a/project/jni/application/gemrb/src/plugins/WEDImporter/WEDImporter.cpp +++ b/project/jni/application/gemrb/gemrb/plugins/WEDImporter/WEDImporter.cpp @@ -117,6 +117,10 @@ int WEDImporter::AddOverlay(TileMap *tm, Overlay *overlays, bool rain) } TileOverlay *over = new TileOverlay( overlays->Width, overlays->Height ); DataStream* tisfile = gamedata->GetResource(res, IE_TIS_CLASS_ID); + if (!tisfile) { + delete over; + return -1; + } PluginHolder tis(IE_TIS_CLASS_ID); tis->Open( tisfile ); for (int y = 0; y < overlays->Height; y++) { @@ -164,6 +168,7 @@ int WEDImporter::AddOverlay(TileMap *tm, Overlay *overlays, bool rain) TileMap* WEDImporter::GetTileMap(TileMap *tm) { int usedoverlays; + bool freenew = false; if (!overlays.size()) { return NULL; @@ -171,9 +176,16 @@ TileMap* WEDImporter::GetTileMap(TileMap *tm) if (!tm) { tm = new TileMap(); + freenew = true; } usedoverlays = AddOverlay(tm, &overlays.at(0), false); + if (usedoverlays == -1) { + if (freenew) { + delete tm; + } + return NULL; + } // rain_overlays[0] is never used // XXX: should fix AddOverlay not to load an overlay twice if there's no rain version!! //AddOverlay(tm, &overlays.at(0), true); diff --git a/project/jni/application/gemrb/src/plugins/WEDImporter/WEDImporter.h b/project/jni/application/gemrb/gemrb/plugins/WEDImporter/WEDImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/WEDImporter/WEDImporter.h rename to project/jni/application/gemrb/gemrb/plugins/WEDImporter/WEDImporter.h diff --git a/project/jni/application/gemrb/src/plugins/WMPImporter/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/WMPImporter/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/WMPImporter/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/WMPImporter/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/WMPImporter/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/WMPImporter/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/WMPImporter/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/WMPImporter/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/WMPImporter/WMPImporter.cpp b/project/jni/application/gemrb/gemrb/plugins/WMPImporter/WMPImporter.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/WMPImporter/WMPImporter.cpp rename to project/jni/application/gemrb/gemrb/plugins/WMPImporter/WMPImporter.cpp diff --git a/project/jni/application/gemrb/src/plugins/WMPImporter/WMPImporter.h b/project/jni/application/gemrb/gemrb/plugins/WMPImporter/WMPImporter.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/WMPImporter/WMPImporter.h rename to project/jni/application/gemrb/gemrb/plugins/WMPImporter/WMPImporter.h diff --git a/project/jni/application/gemrb/src/plugins/ZLibManager/CMakeLists.txt b/project/jni/application/gemrb/gemrb/plugins/ZLibManager/CMakeLists.txt similarity index 100% rename from project/jni/application/gemrb/src/plugins/ZLibManager/CMakeLists.txt rename to project/jni/application/gemrb/gemrb/plugins/ZLibManager/CMakeLists.txt diff --git a/project/jni/application/gemrb/src/plugins/ZLibManager/Makefile.am b/project/jni/application/gemrb/gemrb/plugins/ZLibManager/Makefile.am similarity index 100% rename from project/jni/application/gemrb/src/plugins/ZLibManager/Makefile.am rename to project/jni/application/gemrb/gemrb/plugins/ZLibManager/Makefile.am diff --git a/project/jni/application/gemrb/src/plugins/ZLibManager/ZLibManager.cpp b/project/jni/application/gemrb/gemrb/plugins/ZLibManager/ZLibManager.cpp similarity index 100% rename from project/jni/application/gemrb/src/plugins/ZLibManager/ZLibManager.cpp rename to project/jni/application/gemrb/gemrb/plugins/ZLibManager/ZLibManager.cpp diff --git a/project/jni/application/gemrb/src/plugins/ZLibManager/ZLibManager.h b/project/jni/application/gemrb/gemrb/plugins/ZLibManager/ZLibManager.h similarity index 100% rename from project/jni/application/gemrb/src/plugins/ZLibManager/ZLibManager.h rename to project/jni/application/gemrb/gemrb/plugins/ZLibManager/ZLibManager.h diff --git a/project/jni/application/gemrb/src/AUTHORS b/project/jni/application/gemrb/src/AUTHORS deleted file mode 100644 index 28a7ad991..000000000 --- a/project/jni/application/gemrb/src/AUTHORS +++ /dev/null @@ -1,17 +0,0 @@ -GemRB authors listed in Alphabetical Order - -Alyssa Milburn -Avenger -Balrog994 -Brian Tanedo -Dark-Star -Divide -Edheldil -GuidoJ -Jaka Kranjc -Lotana -Marshall Mattingly III -Thuy Nguyen -Tom Prince -Willem Jan Palenstijn -Zefklop diff --git a/project/jni/application/gemrb/src/COPYING b/project/jni/application/gemrb/src/COPYING deleted file mode 100644 index 5b6e7c66c..000000000 --- a/project/jni/application/gemrb/src/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/project/jni/application/gemrb/src/NEWS b/project/jni/application/gemrb/src/NEWS deleted file mode 100644 index 961e2a864..000000000 --- a/project/jni/application/gemrb/src/NEWS +++ /dev/null @@ -1,381 +0,0 @@ -GemRB git (2bd6d0e): - New features: - - - - Improved features: - - - - bugfixes - - Applied patches: - -GemRB V0.6.3 git (2010-11-21) - New features: - - IWD:HoW is now completable! - - casting sounds and footsteps - - autodetection of secret doors, detect illusions - - basic bardsong support and selective magic resistance (bg2-style) - - proper store economics, ergonomics and dragging - - custom blood color (creature-dependant) - - new actions, iwd effects and triggers - - Importing a SoA game into ToB - - Improved features: - - actor selection and action bar (for summons and illusions too!) - - door bashing and traps - - loading screens, ambushes, worldmap - - sparkles, panic and other effects - - actions, dialogs, object matching - - personal items support (swap/equip/remove) - - bugfixes - - Applied patches: - iwd regression fix from Eggert Jón Magnússon - -GemRB V0.6.2 (2010-08-21): - New features: - - a basic SDL_mixer plugin for faster, but lower-quality audio - - dualclassing for bg1 and iwd - - new triggers, actions, infravision - - feet circle flickering on portrait hover, coloration in dialog - - wisdom xp bonus (pst) - - Improved features: - - actions, triggers, object matching - - item loading and ability selection, inventory - - projectiles, effects, subtitles, verbal constants - - the core and guiscript design was cleaned up in many places - - bugfixes - - Applied patches: - backslash check patch from anthiste - bg1 character generation patch from Maighstir - a crosscompiling fix from F.Fischer - -GemRB V0.6.1 (2010-06-16): - New features: - - a minimal dataset - - reputation penalties on death or injury - - casting level bonus/malus (wild mages, clerics) - - tinting for different times of the day and weather effects - - a BI(n)K player plugin for the IWD2 movies - - new actions, turn undead - - Improved features: - - the internal design was cleaned up in many places - - game saving, modal actions, combat, effects, spawns - - magic missiles are now drawn properly - - various guiscripts (no more flickering!) - - bugfixes - - Applied patches: - two patches from Brendan Molloy - -GemRB V0.6.0 (2009-11-03): - New features: - - BG1 and IWD are roughly completable! - - levelup support for bg1 and iwd, dream cutscenes in ToB - - more hardcoded projectiles and avatar animations - - evasion, backstabbing and basic hide in shadows - - compatibility with the widescreen mod (unreleased) allows for multiple - custom resolutions - - contingency and sequencer spells, beginnings of wild magic support - - Improved features: - - combat, travelling and feedback - - better spellcasting timing - - actions, effects and triggers - - various guiscripts - - bugfixes - - Applied patches: - a few patches from nugrud for how/totl support - -GemRB V0.5.1 (2009-08-27): - New features: - - BG2:SoA is roughly completable! - - almost all missing IE's hardcoded projectiles, spell hit projectiles, - projectile trails, projectile failure (spell), projectile effectlists - - auto-reloading of projectile weapons in case the ammo stack runs out - - damage resistance - - sorcerer style spellbooks, reading of iwd2 spellbooks - - target following to other areas - - the null sound plugin is now always loaded last by default; for old - installs see the provided configuration example (DelayPlugin) - - intelligence and wisdom dictated lore bonus - - a GUIEnhancements config option (on by default) that enables a few - extra controls (for convenience and larger mods) - - PST death counters (don't anger the Lady) - - initial support for targetting by portrait - - Improved features: - - actions, effects and triggers - - pathfinding, feet circles, fog of war and worldmap travel - - combat and spellcasting (especially summoning) - - projectiles - - config and default table value parsing is smarter about spaces - - various guiscripts - - bugfixes - - Applied patches: - various patches from nugrud for bg2 gui enhancements - fix compilation (with cmake) on OS X, by hanicka - -GemRB V0.5.0 (2009-06-25): - New features: - - SoA, ToB and PST are roughly playable beyond their first levels - - combat: dual-wielding, APR, proficiency and style boni, dexterity - bonus, initiatitive and speed factor, individual combat rounds - - many IE's hardcoded projectiles and support for projectile sounds - - IWD2 GUI now works after chargen too - - bg2 chargen now levels to the correct level - - summoned and charmed creatures can be ordered around - - actor tooltips (name and injury status) - - running, initial variable values and portal animations in PST - - hardcoded monk bonuses - - Improved features: - - dialog, actions and triggers - - combat mechanics, animation, feedback, ranged combat - - matters of time and matter - - levelup, dual classing, multiclass handling - - focus: scrolling while paused is now possible - - animations (projectile, creature) - - pathfinding - - area music restarts when there's no music playing - - disarm trap checks skills - - various guiscripts - - bugfixes - - Applied patches: - #2802190 jbmetz (improve the rpm spec handling) - #2802437 danamin (patch bomb sanitizing bg1 chargen + bg2 code share) - -GemRB V0.4.0 (2009-05-25): - New features: - - level up support in bg2 - - basic party reordering - - bashing of containers and doors - - persistent area effects (cloudkill, stinking cloud, web, etc.) - - item amount window for stack splitting (shift+click or doubleclick) - - depletion of item charges - - opcodes: disable spellcasting, cutscene2 (pocketplane travel), knock, - clear air, polymorph, disable button - - dynamic scrollbar creation (display of more than 10 kits, 24 spells) - - portrait effect icons - - item ability selection - - character customization - - Improved features: - - fog of war - - party reformation - - iwd and how guiscripts have been merged - - traps - - pst dialogs - - regeneration, hp bonuses, healing - - animations and projectiles - - rewritten MVE player - - ranged combat - - various guiscripts - - bugfixes - - Applied patches: - #2770564 Whiteclone (pst options window bug) - numerous patches from mattinm finishing the level up support - a few patches from ape fixing and extending iwd - #2579743 jbmetz added RPM spec files - -GemRB V0.3.2 (2009-02-16): - New features: - - default cancel button, bound to the escape key - - tooltip animations and a shortcut (tab) - - wrapper python classes that simplified the GUIScripts - - trap detection, removal, triggering, xp, feedback, autopause - - modal effects - - proper xp award for dual- and multiclass actors - - double click (used in the map window) - - click-and-hold incrementing/decrementing - - accumulate kill statistics - - characters can move while the map is open - - sound on item equip - - arbitrary feat prerequisites in iwd2 - - hard pause for all games (originally a ToB feature); triggered with 'h' - - extended night areas (originally a bg2 feature) - - Improved features: - - walking animation timing - - formations (arbitrary sizes, rotation, cursor) - - ppc support (no more crashes) - - container/door/infopoint cursor and highlight handling - - various guiscripts - - cmake build system (now really works on *nix) - - magic item exclusion - - stores and bags - - fixed attack loop when target dies - - bugfixes - - Applied patches: - #2159734 Zefklop (Mouse activity during movies) - #2243323 Zefklop (correct Openal cleanup) - #2263333 Whiteclone (bg1 guiinv) - #2380891 Amikrop (iwd1 guicommonwindows) - -GemRB V0.3.1 (2008-09-25): - New features: - - mouse scroll support - - starting tob inventory - - character import in iwd and how - - spritecover for area animations - - proper XP bonus for thieving and learning spells - - Improved features: - - gcc 4.3 compatibility - - PST bestiary - - bg2 and tob game modes have been merged - - bg2 and iwd2 character generation was simplified and improved - - stricter dualclassing prerequisites - - the cmake build system is available for other platforms too - - pathfinding - - starting time is now at day 0 - - less memory leaks - - bugfixes - -GemRB V0.3.0 (2008-02-17): - New features: - - TLK override handling (custom biographies and map notes) - - weapon immunities - - party AI - - expansion playmode - - more actions, triggers and effects - - loading of projectile explosion animations - - kit information window - - optional CMake build system (windows only) - - Improved features: - - sound (now perfect!) - - character generation - - opcodes - - character record window - - pathfinding - - tooltip delay - - bugfixes - -GemRB V0.2.9 (2007-07-06): - New features: - - thieving - - tracking - - graphical feedback (color pulse, blur, mirror image, vvc overlays etc) - - projectiles - - spell casting - - item use - - challenge rating calculation - - Improved features: - - more opcodes - - bugfixes - - shop/inventory gui - -GemRB V0.2.8 (2006-12-24): - New features: - - equipment is rendered both on paperdoll and avatar - - weather (snow/rain) is now rendered - - Improved features: - - action menus - - game scripting (actions/triggers) - -GemRB V0.2.7 (2006-08-30): - New features: - - large animations - - worldmap travel - - dialogue portraits - - translucent shadows option - - personal space of actors - - combat - - many new effects - - overlay animation - - Improved features: - - Script fixes - - Action menus - - TextScreen - - doors - - animated overlays - - new actions - -GemRB V0.2.6 (2005-12-06): - New features: - - Effects are in a different plugin - - DoxyGen docs - - Wallgroup covers - - Door triggers - - Action menus (talk/attack) - - party/protagonist death handled - - Improved features: - - Textscreen graphic fixed - - script workflow - - compilation and running on different systems (MacOSX, PPC Linux) - - various leaks/instabilities fixed - - Saving games - - inventory screens in many games - -GemRB V0.2.5 (2005-08-22): - New features: - - Save game - - Effects are now loaded - - Equipping effects in items - - Spawn points in areas - - Textscreen (scrolled text between chapters) - - Improved features: - - GameScript is now much more reliable: Action override works, triggers fire once and then get cleared - - fully working Store screen - - fixed padding of message window rows (in dialogs) - -GemRB V0.2.4 (2005-05-29): - New features: - - Store dialogs (Temple, Inn, Container, Tavern, Store) - - Fog of war with line of sight - - Doors block path and line of sight - - Window frames at higher resolutions - - Animated buttons (PST portraits, Donation window) - - Store opens when appropriate - - Containers - - Improved features: - - Fixed dialogs - - new GUIScript functions with documentation - - Fog of war/door/store related gamescript actions - - fixed object distance and area variable handling in gamescript - - other new gamescript actions/triggers - - Implemented PCs fidget animations - - Documentation: - - Introduction to writing GUIScript scripts - -GemRB v0.2.3 (2005-02-13): - New features: - - GUI for most of the games, especially interactive Inventory and Spellbook - - Map and WorldMap - - Load screen interstitials with progress bar - - Spell and item cache to speed up object management - - Added gamescript actions/triggers - - Selection of spells during character generation - - First attempt on effects code - - First attempt on Fog-Of-War - - Tooltips - - Overhead text - - Ambient sounds - - Volume control - - Manual page gemrb(1) - - Documentation for GemRB Python API and our custom override files - - Improved features: - - Character generation - - GUI - - Build infrastructure on Linux and Un*x systems - - Progress towards portability to 64 bit and big endian machines - - Many bugfixes and new bugs as well ;-) - - Shortened version numbers - - Simplified user configuration, game specific settings are now - in gemrb/override dir diff --git a/project/jni/application/gemrb/src/README b/project/jni/application/gemrb/src/README deleted file mode 100644 index 8d3b71955..000000000 --- a/project/jni/application/gemrb/src/README +++ /dev/null @@ -1,77 +0,0 @@ -Introduction ------------- -GemRB (Game Engine Made with preRendered Background) is a "port" -(actually a new implementation) of the original Infinity Engine (the one -of Baldur's Gate, Icewind Dale, Planescape: Torment, ...) to -Linux/Unix, MacOS X and Windows with some enhancements. Would you like to -create a game like Baldur's Gate? - -It means that you either need some of the original game's data -somewhere on your harddisk, or you can try to use the data from the -Dragonlance Total Conversion project - see the link below. - -The original game data has to be installed on a windows -partition and mounted to your Linux/Unix filesystem, installed on -windows and then copied to your filesystem, installed with WINE or -extracted manually from the CDs using the tool `unshield'. - -What little documentation exists is mostly in gemrb/docs/en/ and -subdirectories, the gemrb.6 man page and this file. - -Supported platforms -------------------- -Supported (i.e. we got reports about successfully running GemRB) systems: -Linux x86, x86-64, ppc -FreeBSD x86 -MS Windows (98, XP or Vista) -various Macintosh systems (even pre x86) also should work ... -some smart phones (Symbian, Android) -some consoles (OpenPandora, Dingoo) -some exotic OSes (ReactOS, SyllableOS, Haiku) - -Requirements ------------- -See the INSTALL file. - -Contacts --------- -Our homepage: -http://gemrb.sourceforge.net - -Our project at sourceforge.net: -http://sourceforge.net/projects/gemrb - -New GemRB forum (users): -http://forums.gibberlings3.net/index.php?showforum=91 - -IRC channel: -The best way to talk with us is by joining the #GemRB channel -on the FreeNode IRC network. There's somebody to talk with most of -the time. - - -Useful links ------------- -IESDP, documentation for the Infinity Engine file formats and more: -http://iesdp.gibberlings3.net/ - -Near Infinity, Java viewer and editor for data files of the original games: -http://www.idi.ntnu.no/~joh/ni/index.html - -DLTCEP, MS Windows viewer and editor for data files of the original games: -http://forums.gibberlings3.net/index.php?showforum=137 - -Unshield, extractor for .CAB files created by InstallShield -http://synce.sourceforge.net/synce/unshield.php - -Valgrind, a powerful developer tool to fix programmer errors (leaks, buffer overflows and all the like that happen) -http://valgrind.org/ - -SDL, Simple Directmedia Layer, the graphical library used for GemRB -http://www.libsdl.org/index.php - -OpenAL, Cross-Platform 3D audio libraries, the sound library used for GemRB -http://openal.org/ - -WINE, Open Source implementation of the Windows API, useful for installing the games -http://www.winehq.org diff --git a/project/jni/application/gemrb/src/TODO b/project/jni/application/gemrb/src/TODO deleted file mode 100644 index 2f1af016a..000000000 --- a/project/jni/application/gemrb/src/TODO +++ /dev/null @@ -1,101 +0,0 @@ -Scripts: -1. (DONE?) ToB specific actions/triggers, like pocketplane (so ToB will work) -2. (PARTLY) Properly detect the play mode (sp/mp, normal/extended) - -Strings: -1. fix (finish implementation of) talk table override -2. implement feature: "" (or even more ambitious stat specific strref tokens) - -Combat: -1. (PARTLY) fix combat round timings -2. implement customisable combat calculation, it should be general enough to -simulate all games, without any hardcoded parts - -Items: -1. (DONE-almost) Break items, count charges -2. (PARTLY) Implement switching weapon abilities -3. (DONE-almost) Implement item usage (similar to spells) - -Effects: -1. (DONE-almost) Implement common effects -2. (PARTLY) Implement IWD2 effects -3. (DONE-almost) Implement TOB effects -4. (PARTLY) Implement PST effects -5. (DONE-almost) Implement area/non-living affecting effects - -Area: -1. (PARTLY) Don't load scripts for pile items? (research when a script is unused) -2. (DONE) Create real streaming ambients (do not preload them, just use them when needed) -3. (DONE) in pathfinder, calculate with the actor's feet circle size (npc blocking still needed) -4. (DONE-almost) fix overlaid tiles - bug #1623839 - -Store: -1. Store caching (especially bags) - -Animation: -1. (PARTLY) fix char animation sequences -2. stanceID is still fuzzy. Fix it. (FIXED?) -3. (PARTLY) Implement projectile animations (area, cone, fragments, hardcoded features) - -Actor: -1. (PARTLY) Use the character sheet (Actor.cpp) itself to store attributes of the character - during character generation. - Benefits: data is already stored in the destination, data constraints and relations - are easily implemented. - How to: replace GemRB.SetVar with GemRB.SetPlayerStat. Don't forget to create - the character first. - see bg1 chargen for a complete solution -2. Move position of actor (and ground circle) to the center of a searchmap cell -3. (PARTLY) Actually handle the iwd2 spelllists. Exporter is still needed. - -Game GUI: -1. (PARTLY) implement class based (but customisable) action button bar. Generally port - the IWD2 system to all engines -2. implement grabbing mouse pointer by a control to fix dragging of PST Float menu window -3. (PARTLY) Fix drop capitals (initials) Calculate text height/width correctly, display - it correctly too. -4. (PARTLY) Fix unwanted screen shake (especially when on bottom of area) -5. (DONE-almost) Level up code, this should be written mostly in GuiScript!!! -6. (PARTLY) Contingency, spell trigger setup windows -7. (PARTLY) Customize windows (part of character record window) - -General: -1. The Cache and Variables classes could be rewritten to incorporate the release - function more smoothly (use templates?) -2. various directories (GemRB override, game override ...) should be resolved - right after loading config files and remain static afterwards. Maybe define - some PATH variable describing all the directories searched for files -3. valgrind reports a big heap of unreleased python objects -4. Implement at least all the options accessible from the GUI options setup, - rewrite baldur|torment|icewind.ini - -Graphics: -1. use scaling in Video::SpriteScaleDown() instead of in Video::GetPreview() - and in BMPImporter -2. move SDLVideoDriver sprite functions to their own file, rename them to - SpriteIsPixelTransparent etc. -3. (PARTLY) Add PNG support? (still image done) -4. Fog of war: fully visible squares with one corner neighbour invisible need alpha of the adjacent corner to the invisible square tuned down (uh, i hope it is clear what to do, look for artifacts in the fog of war edge) - -Sound: -1. valgrind reports invalid memory access due to Unqueueing buffers and using - them in another thread (openal weirdness?) -2. (PARTLY) sounds get sometimes distorted, might be connected to problem #1 -3. (PARTLY) Separate OpenAL interface from ACM loader and MVE player -4. implement sound handles so looping, moving sound, stopping sound is possible -5. fix sound settings (currently the volumes get reset on area change, for example) -6. implement and use as much from EAX (echo, damping, etc) as possible - -Release: -2. Get a sample game with some free license which could be distributed - with GemRB. - - -Documentation: -1. (PARTLY) make tool to scan source files for those with non-standard - copyright notices -2. Add Doxygen doc comments to more objects -3. Write GemRB overview, structure and high-level flow docs - - -Community: -2. Move this todo to bug/task tracker at Sourceforge :-) diff --git a/project/jni/application/gemrb/src/plugins/BIKPlayer/GetBitContext.h b/project/jni/application/gemrb/src/plugins/BIKPlayer/GetBitContext.h deleted file mode 100644 index 42b1091e9..000000000 --- a/project/jni/application/gemrb/src/plugins/BIKPlayer/GetBitContext.h +++ /dev/null @@ -1,75 +0,0 @@ -/* GemRB - Infinity Engine Emulator - * Copyright (C) 2009 The GemRB Project - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * - */ - -//code derived from FFMPEG -//using code from get_bits.h, bitstream.c - -#include "common.h" - -#define INIT_VLC_LE 2 -#define INIT_VLC_USE_NEW_STATIC 4 - -class VLC -{ -public: - int bits; - int16_t (*table)[2]; ///< code, bits - int table_size, table_allocated; -public: -int init_vlc(int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - int flags); -private: - int alloc_table(int size); - int build_table(int table_nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - uint32_t code_prefix, int n_prefix, int flags); - -}; - - -#define AV_RL32(x) \ - ((((const uint8_t*)(x))[3] << 24) | \ - (((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) - -class GetBitContext -{ -public: - const uint8_t *buffer, *buffer_end; - int index; - int size_in_bits; -public: - void debug(const char *prefix); - float get_float(); - void skip_bits(int x) { index+=x; } - int get_bits_count() { return index; } - void get_bits_align32(); - unsigned int get_bits(int x); - unsigned int peek_bits(int x); - unsigned int get_bits_long(int n); - void init_get_bits(const uint8_t *b, int bit_size); - void read_tree(Tree *tree); -private: - void merge( uint8_t *dst, uint8_t *src, int size); -}; diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/mvevideodec16.cpp b/project/jni/application/gemrb/src/plugins/MVEPlayer/mvevideodec16.cpp deleted file mode 100644 index 0d4713119..000000000 --- a/project/jni/application/gemrb/src/plugins/MVEPlayer/mvevideodec16.cpp +++ /dev/null @@ -1,849 +0,0 @@ -/* - * Interplay MVE Video Decoder (16 bit) - * Copyright (C) 2003 the ffmpeg project, Mike Melanson - * (C) 2006 Jens Granseuer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * For more information about the Interplay MVE format, visit: - * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt - */ - -#include "gstmvedemux.h" -#include - -#define PIXEL(s) GST_READ_UINT16_LE (s) - -#define CHECK_STREAM(l, n) \ - do { \ - if (G_UNLIKELY (*(l) < (n))) { \ - GST_ERROR ("wanted to read %d bytes from stream, %d available", (n), *(l)); \ - return -1; \ - } \ - *(l) -= (n); \ - } while (0) - -/* copy an 8x8 block from the stream to the frame buffer */ -static int -ipvideo_copy_block (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned short *src, int offset) -{ - int i; - int frame_offset; - - frame_offset = frame - (unsigned short *) s->back_buf1 + offset; - - if (G_UNLIKELY (frame_offset < 0)) { - GST_ERROR ("frame offset < 0 (%d)", frame_offset); - return -1; - } else if (G_UNLIKELY ((guint32)frame_offset > s->max_block_offset)) { - GST_ERROR ("frame offset above limit (%d > %u)", - frame_offset, s->max_block_offset); - return -1; - } - - for (i = 0; i < 8; ++i) { - memcpy (frame, src, 16); - frame += s->width; - src += s->width; - } - - return 0; -} - -static int -ipvideo_decode_0x2 (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - unsigned char B; - int x, y; - int offset; - - /* copy block from 2 frames ago using a motion vector */ - CHECK_STREAM (len, 1); - B = *(*data)++; - - if (B < 56) { - x = 8 + (B % 7); - y = B / 7; - } else { - x = -14 + ((B - 56) % 29); - y = 8 + ((B - 56) / 29); - } - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, frame + offset, offset); -} - -static int -ipvideo_decode_0x3 (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - unsigned char B; - int x, y; - int offset; - - /* copy 8x8 block from current frame from an up/left block */ - CHECK_STREAM (len, 1); - B = *(*data)++; - - if (B < 56) { - x = -(8 + (B % 7)); - y = -(B / 7); - } else { - x = -(-14 + ((B - 56) % 29)); - y = -(8 + ((B - 56) / 29)); - } - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, frame + offset, offset); -} - -static int -ipvideo_decode_0x4 (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char B; - int offset; - - /* copy a block from the previous frame */ - CHECK_STREAM (len, 1); - B = *(*data)++; - x = -8 + (B & 0x0F); - y = -8 + (B >> 4); - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, frame + - ((unsigned short *) s->back_buf2 - (unsigned short *) s->back_buf1) + - offset, offset); -} - -static int -ipvideo_decode_0x5 (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - signed char x, y; - int offset; - - /* copy a block from the previous frame using an expanded range */ - CHECK_STREAM (len, 2); - x = (signed char) *(*data)++; - y = (signed char) *(*data)++; - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, frame + - ((unsigned short *) s->back_buf2 - (unsigned short *) s->back_buf1) + - offset, offset); -} - -static int -ipvideo_decode_0x7 (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short P0, P1; - unsigned int flags; - int bitmask; - - /* 2-color encoding */ - CHECK_STREAM (len, 4 + 2); - P0 = PIXEL (*data); - (*data) += 2; - P1 = PIXEL (*data); - (*data) += 2; - - if (!(P0 & 0x8000)) { - - /* need 8 more bytes from the stream */ - CHECK_STREAM (len, 8 - 2); - - for (y = 0; y < 8; ++y) { - flags = *(*data)++; - for (x = 0x01; x <= 0x80; x <<= 1) { - if (flags & x) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - - } else { - P0 &= ~0x8000; - - /* need 2 more bytes from the stream */ - - flags = ((*data)[1] << 8) | (*data)[0]; - (*data) += 2; - bitmask = 0x0001; - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2, bitmask <<= 1) { - if (flags & bitmask) { - *(frame + x) = P1; - *(frame + x + 1) = P1; - *(frame + s->width + x) = P1; - *(frame + s->width + x + 1) = P1; - } else { - *(frame + x) = P0; - *(frame + x + 1) = P0; - *(frame + s->width + x) = P0; - *(frame + s->width + x + 1) = P0; - } - } - frame += s->width * 2; - } - } - - return 0; -} - -static int -ipvideo_decode_0x8 (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short P[8]; - unsigned char B[8]; - unsigned int flags = 0; - unsigned int bitmask = 0; - unsigned short P0 = 0, P1 = 0; - int lower_half = 0; - - /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on - * either top and bottom or left and right halves */ - CHECK_STREAM (len, 6 + 10); - - P[0] = PIXEL (*data); - (*data) += 2; - P[1] = PIXEL (*data); - (*data) += 2; - B[0] = *(*data)++; - B[1] = *(*data)++; - - if (!(P[0] & 0x8000)) { - - /* need 18 more bytes */ - CHECK_STREAM (len, 18 - 10); - - P[2] = PIXEL (*data); - (*data) += 2; - P[3] = PIXEL (*data); - (*data) += 2; - B[2] = *(*data)++; - B[3] = *(*data)++; - P[4] = PIXEL (*data); - (*data) += 2; - P[5] = PIXEL (*data); - (*data) += 2; - B[4] = *(*data)++; - B[5] = *(*data)++; - P[6] = PIXEL (*data); - (*data) += 2; - P[7] = PIXEL (*data); - (*data) += 2; - B[6] = *(*data)++; - B[7] = *(*data)++; - - flags = - ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | - ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | - ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | - ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); - bitmask = 0x00000001; - lower_half = 0; /* still on top half */ - - for (y = 0; y < 8; ++y) { - - /* time to reload flags? */ - if (y == 4) { - flags = - ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | - ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | - ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | - ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); - bitmask = 0x00000001; - lower_half = 2; - } - - /* get the pixel values ready for this quadrant */ - P0 = P[lower_half + 0]; - P1 = P[lower_half + 1]; - - for (x = 0; x < 8; ++x, bitmask <<= 1) { - if (x == 4) { - P0 = P[lower_half + 4]; - P1 = P[lower_half + 5]; - } - - if (flags & bitmask) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - - } else { - P[0] &= ~0x8000; - - /* need 10 more bytes */ - B[2] = *(*data)++; - B[3] = *(*data)++; - P[2] = PIXEL (*data); - (*data) += 2; - P[3] = PIXEL (*data); - (*data) += 2; - B[4] = *(*data)++; - B[5] = *(*data)++; - B[6] = *(*data)++; - B[7] = *(*data)++; - - if (!(P[2] & 0x8000)) { - /* vertical split; left & right halves are 2-color encoded */ - - flags = - ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | - ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | - ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | - ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); - bitmask = 0x00000001; - - for (y = 0; y < 8; ++y) { - - /* time to reload flags? */ - if (y == 4) { - flags = - ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | - ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | - ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | - ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); - bitmask = 0x00000001; - } - - /* get the pixel values ready for this half */ - P0 = P[0]; - P1 = P[1]; - - for (x = 0; x < 8; ++x, bitmask <<= 1) { - if (x == 4) { - P0 = P[2]; - P1 = P[3]; - } - - if (flags & bitmask) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - - } else { - /* horizontal split; top & bottom halves are 2-color encoded */ - - P0 = P[0]; - P1 = P[1]; - - for (y = 0; y < 8; ++y) { - - flags = B[y]; - if (y == 4) { - P0 = P[2] & ~0x8000; - P1 = P[3]; - } - - for (bitmask = 0x01; bitmask <= 0x80; bitmask <<= 1) { - - if (flags & bitmask) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - } - } - - return 0; -} - -static int -ipvideo_decode_0x9 (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short P[4]; - unsigned char B[4]; - unsigned int flags = 0; - int shifter = 0; - unsigned short pix; - - /* 4-color encoding */ - CHECK_STREAM (len, 8 + 4); - - P[0] = PIXEL (*data); - (*data) += 2; - P[1] = PIXEL (*data); - (*data) += 2; - P[2] = PIXEL (*data); - (*data) += 2; - P[3] = PIXEL (*data); - (*data) += 2; - - if (!(P[0] & 0x8000) && !(P[2] & 0x8000)) { - - /* 1 of 4 colors for each pixel, need 16 more bytes */ - CHECK_STREAM (len, 16 - 4); - - for (y = 0; y < 8; ++y) { - /* get the next set of 8 2-bit flags */ - flags = ((*data)[1] << 8) | (*data)[0]; - (*data) += 2; - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { - *frame++ = P[(flags >> shifter) & 0x03]; - } - frame += s->width - 8; - } - - } else if (!(P[0] & 0x8000) && (P[2] & 0x8000)) { - P[2] &= ~0x8000; - - /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ - - B[0] = *(*data)++; - B[1] = *(*data)++; - B[2] = *(*data)++; - B[3] = *(*data)++; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(frame + x) = pix; - *(frame + x + 1) = pix; - *(frame + s->width + x) = pix; - *(frame + s->width + x + 1) = pix; - } - frame += s->width * 2; - } - - } else if ((P[0] & 0x8000) && !(P[2] & 0x8000)) { - P[0] &= ~0x8000; - - /* 1 of 4 colors for each 2x1 block, need 8 more bytes */ - - CHECK_STREAM (len, 8 - 4); - for (y = 0; y < 8; ++y) { - /* time to reload flags? */ - if ((y == 0) || (y == 4)) { - B[0] = *(*data)++; - B[1] = *(*data)++; - B[2] = *(*data)++; - B[3] = *(*data)++; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - } - for (x = 0; x < 8; x += 2, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(frame + x) = pix; - *(frame + x + 1) = pix; - } - frame += s->width; - } - - } else { - P[0] &= ~0x8000; - P[2] &= ~0x8000; - - /* 1 of 4 colors for each 1x2 block, need 8 more bytes */ - CHECK_STREAM (len, 8 - 4); - - for (y = 0; y < 8; y += 2) { - /* time to reload flags? */ - if ((y == 0) || (y == 4)) { - B[0] = *(*data)++; - B[1] = *(*data)++; - B[2] = *(*data)++; - B[3] = *(*data)++; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - } - for (x = 0; x < 8; ++x, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(frame + x) = pix; - *(frame + s->width + x) = pix; - } - frame += s->width * 2; - } - } - - return 0; -} - -static int -ipvideo_decode_0xa (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short P[16]; - unsigned char B[16]; - int flags = 0; - int shifter = 0; - int index; - int split; - int lower_half; - - /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on - * either top and bottom or left and right halves */ - CHECK_STREAM (len, 8 + 24); - - P[0] = PIXEL (*data); - (*data) += 2; - P[1] = PIXEL (*data); - (*data) += 2; - P[2] = PIXEL (*data); - (*data) += 2; - P[3] = PIXEL (*data); - (*data) += 2; - - if (!(P[0] & 0x8000)) { - - /* 4-color encoding for each quadrant; need 40 more bytes */ - CHECK_STREAM (len, 40 - 24); - - B[0] = *(*data)++; - B[1] = *(*data)++; - B[2] = *(*data)++; - B[3] = *(*data)++; - for (y = 4; y < 16; y += 4) { - for (x = y; x < y + 4; ++x) { - P[x] = PIXEL (*data); - (*data) += 2; - } - for (x = y; x < y + 4; ++x) - B[x] = *(*data)++; - } - - for (y = 0; y < 8; ++y) { - - lower_half = (y >= 4) ? 4 : 0; - flags = (B[y + 8] << 8) | B[y]; - - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { - split = (x >= 4) ? 8 : 0; - index = split + lower_half + ((flags >> shifter) & 0x03); - *frame++ = P[index]; - } - - frame += s->width - 8; - } - - } else { - P[0] &= ~0x8000; - - /* 4-color encoding for either left and right or top and bottom - * halves; need 24 more bytes */ - - memcpy (&B[0], *data, 8); - (*data) += 8; - P[4] = PIXEL (*data); - (*data) += 2; - P[5] = PIXEL (*data); - (*data) += 2; - P[6] = PIXEL (*data); - (*data) += 2; - P[7] = PIXEL (*data); - (*data) += 2; - memcpy (&B[8], *data, 8); - (*data) += 8; - - if (!(P[4] & 0x8000)) { - - /* block is divided into left and right halves */ - for (y = 0; y < 8; ++y) { - - flags = (B[y + 8] << 8) | B[y]; - split = 0; - - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { - if (x == 4) - split = 4; - *frame++ = P[split + ((flags >> shifter) & 0x03)]; - } - - frame += s->width - 8; - } - - } else { - P[4] &= ~0x8000; - - /* block is divided into top and bottom halves */ - split = 0; - for (y = 0; y < 8; ++y) { - - flags = (B[y * 2 + 1] << 8) | B[y * 2]; - if (y == 4) - split = 4; - - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) - *frame++ = P[split + ((flags >> shifter) & 0x03)]; - - frame += s->width - 8; - } - } - } - - return 0; -} - -static int -ipvideo_decode_0xb (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - - /* 64-color encoding (each pixel in block is a different color) */ - CHECK_STREAM (len, 128); - - for (y = 0; y < 8; ++y) { - for (x = 0; x < 8; ++x) { - *frame++ = PIXEL (*data); - (*data) += 2; - } - frame += s->width - 8; - } - - return 0; -} - -static int -ipvideo_decode_0xc (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short pix; - - /* 16-color block encoding: each 2x2 block is a different color */ - CHECK_STREAM (len, 32); - - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2) { - pix = PIXEL (*data); - (*data) += 2; - *(frame + x) = pix; - *(frame + x + 1) = pix; - *(frame + s->width + x) = pix; - *(frame + s->width + x + 1) = pix; - } - frame += s->width * 2; - } - - return 0; -} - -static int -ipvideo_decode_0xd (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short P[4]; - unsigned char index = 0; - - /* 4-color block encoding: each 4x4 block is a different color */ - CHECK_STREAM (len, 8); - - P[0] = PIXEL (*data); - (*data) += 2; - P[1] = PIXEL (*data); - (*data) += 2; - P[2] = PIXEL (*data); - (*data) += 2; - P[3] = PIXEL (*data); - (*data) += 2; - - for (y = 0; y < 8; ++y) { - if (y < 4) - index = 0; - else - index = 2; - - for (x = 0; x < 8; ++x) { - if (x == 4) - ++index; - *frame++ = P[index]; - } - frame += s->width - 8; - } - - return 0; -} - -static int -ipvideo_decode_0xe (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short pix; - - /* 1-color encoding: the whole block is 1 solid color */ - CHECK_STREAM (len, 2); - - pix = PIXEL (*data); - (*data) += 2; - - for (y = 0; y < 8; ++y) { - for (x = 0; x < 8; ++x) { - *frame++ = pix; - } - frame += s->width - 8; - } - - return 0; -} - -static int -ipvideo_decode_0xf (const GstMveDemuxStream * s, unsigned short *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned short P[2]; - - /* dithered encoding */ - CHECK_STREAM (len, 4); - - P[0] = PIXEL (*data); - (*data) += 2; - P[1] = PIXEL (*data); - (*data) += 2; - - for (y = 0; y < 8; ++y) { - for (x = 0; x < 4; ++x) { - *frame++ = P[y & 1]; - *frame++ = P[(y & 1) ^ 1]; - } - frame += s->width - 8; - } - - return 0; -} - -int -ipvideo_decode_frame16 (const GstMveDemuxStream * s, const unsigned char *data, - unsigned short len) -{ - int rc = 0; - int x, y, xx, yy; - int index = 0; - unsigned short offset; - unsigned char opcode; - unsigned short *frame; - const unsigned char *data2; - unsigned short len2; - - CHECK_STREAM (&len, 2); - - offset = (data[1] << 8) | data[0]; - data2 = data + offset; - len2 = len - offset + 2; - data += 2; - - frame = (unsigned short *) s->back_buf1; - - /* decoding is done in 8x8 blocks */ - xx = s->width >> 3; - yy = s->height >> 3; - - for (y = 0; y < yy; ++y) { - for (x = 0; x < xx; ++x) { - /* decoding map contains 4 bits of information per 8x8 block */ - /* bottom nibble first, then top nibble */ - if (index & 1) - opcode = s->code_map[index >> 1] >> 4; - else - opcode = s->code_map[index >> 1] & 0x0F; - ++index; - - /* GST_DEBUG ("block @ (%3d, %3d): encoding 0x%X, data ptr @ %p", - x, y, opcode, data); */ - - switch (opcode) { - case 0x0: - /* copy a block from the previous frame */ - rc = ipvideo_copy_block (s, frame, frame + - ((unsigned short *) s->back_buf2 - - (unsigned short *) s->back_buf1), 0); - break; - case 0x1: - /* copy block from 2 frames ago; since we switched the back - * buffers we don't actually have to do anything here */ - break; - case 0x2: - rc = ipvideo_decode_0x2 (s, frame, &data2, &len2); - break; - case 0x3: - rc = ipvideo_decode_0x3 (s, frame, &data2, &len2); - break; - case 0x4: - rc = ipvideo_decode_0x4 (s, frame, &data2, &len2); - break; - case 0x5: - rc = ipvideo_decode_0x5 (s, frame, &data, &len); - break; - case 0x6: - /* mystery opcode? skip multiple blocks? */ - GST_WARNING ("encountered unsupported opcode 0x6"); - rc = -1; - break; - case 0x7: - rc = ipvideo_decode_0x7 (s, frame, &data, &len); - break; - case 0x8: - rc = ipvideo_decode_0x8 (s, frame, &data, &len); - break; - case 0x9: - rc = ipvideo_decode_0x9 (s, frame, &data, &len); - break; - case 0xa: - rc = ipvideo_decode_0xa (s, frame, &data, &len); - break; - case 0xb: - rc = ipvideo_decode_0xb (s, frame, &data, &len); - break; - case 0xc: - rc = ipvideo_decode_0xc (s, frame, &data, &len); - break; - case 0xd: - rc = ipvideo_decode_0xd (s, frame, &data, &len); - break; - case 0xe: - rc = ipvideo_decode_0xe (s, frame, &data, &len); - break; - case 0xf: - rc = ipvideo_decode_0xf (s, frame, &data, &len); - break; - } - - if (rc != 0) - return rc; - - frame += 8; - } - frame += 7 * s->width; - } - - return 0; -} diff --git a/project/jni/application/gemrb/src/plugins/MVEPlayer/mvevideodec8.cpp b/project/jni/application/gemrb/src/plugins/MVEPlayer/mvevideodec8.cpp deleted file mode 100644 index 01992e970..000000000 --- a/project/jni/application/gemrb/src/plugins/MVEPlayer/mvevideodec8.cpp +++ /dev/null @@ -1,802 +0,0 @@ -/* - * Interplay MVE Video Decoder (8 bit) - * Copyright (C) 2003 the ffmpeg project, Mike Melanson - * (C) 2006 Jens Granseuer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * For more information about the Interplay MVE format, visit: - * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt - */ - -#include "gstmvedemux.h" -#include - -#define CHECK_STREAM(l, n) \ - do { \ - if (G_UNLIKELY (*(l) < (n))) { \ - GST_ERROR ("wanted to read %d bytes from stream, %d available", (n), *(l)); \ - return -1; \ - } \ - *(l) -= (n); \ - } while (0) - - -/* copy an 8x8 block from the stream to the frame buffer */ -static int -ipvideo_copy_block (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char *src, int offset) -{ - int i; - long frame_offset; - - frame_offset = frame - s->back_buf1 + offset; - - if (G_UNLIKELY (frame_offset < 0)) { - GST_ERROR ("frame offset < 0 (%ld)", frame_offset); - return -1; - } else if (G_UNLIKELY ((guint32)frame_offset > s->max_block_offset)) { - GST_ERROR ("frame offset above limit (%ld > %u)", - frame_offset, s->max_block_offset); - return -1; - } - - for (i = 0; i < 8; ++i) { - memcpy (frame, src, 8); - frame += s->width; - src += s->width; - } - - return 0; -} - -static int -ipvideo_decode_0x2 (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - unsigned char B; - int x, y; - int offset; - - /* copy block from 2 frames ago using a motion vector */ - CHECK_STREAM (len, 1); - B = *(*data)++; - - if (B < 56) { - x = 8 + (B % 7); - y = B / 7; - } else { - x = -14 + ((B - 56) % 29); - y = 8 + ((B - 56) / 29); - } - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, frame + offset, offset); -} - -static int -ipvideo_decode_0x3 (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - unsigned char B; - int x, y; - int offset; - - /* copy 8x8 block from current frame from an up/left block */ - CHECK_STREAM (len, 1); - B = *(*data)++; - - if (B < 56) { - x = -(8 + (B % 7)); - y = -(B / 7); - } else { - x = -(-14 + ((B - 56) % 29)); - y = -(8 + ((B - 56) / 29)); - } - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, frame + offset, offset); -} - -static int -ipvideo_decode_0x4 (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - unsigned char B; - int x, y; - int offset; - - /* copy a block from the previous frame */ - CHECK_STREAM (len, 1); - B = *(*data)++; - x = -8 + (B & 0x0F); - y = -8 + (B >> 4); - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, - frame + (s->back_buf2 - s->back_buf1) + offset, offset); -} - -static int -ipvideo_decode_0x5 (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - signed char x, y; - int offset; - - /* copy a block from the previous frame using an expanded range */ - CHECK_STREAM (len, 2); - - x = (signed char) *(*data)++; - y = (signed char) *(*data)++; - offset = y * s->width + x; - - return ipvideo_copy_block (s, frame, - frame + (s->back_buf2 - s->back_buf1) + offset, offset); -} - -static int -ipvideo_decode_0x7 (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char P0, P1; - unsigned int flags; - int bitmask; - - /* 2-color encoding */ - CHECK_STREAM (len, 2 + 2); - - P0 = *(*data)++; - P1 = *(*data)++; - - if (P0 <= P1) { - - /* need 8 more bytes from the stream */ - CHECK_STREAM (len, 8 - 2); - - for (y = 0; y < 8; ++y) { - flags = *(*data)++; - for (x = 0x01; x <= 0x80; x <<= 1) { - if (flags & x) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - - } else { - - /* need 2 more bytes from the stream */ - flags = ((*data)[1] << 8) | (*data)[0]; - (*data) += 2; - bitmask = 0x0001; - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2, bitmask <<= 1) { - if (flags & bitmask) { - *(frame + x) = P1; - *(frame + x + 1) = P1; - *(frame + s->width + x) = P1; - *(frame + s->width + x + 1) = P1; - } else { - *(frame + x) = P0; - *(frame + x + 1) = P0; - *(frame + s->width + x) = P0; - *(frame + s->width + x + 1) = P0; - } - } - frame += s->width * 2; - } - } - - return 0; -} - -static int -ipvideo_decode_0x8 (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char P[8]; - unsigned char B[8]; - unsigned int flags = 0; - unsigned int bitmask = 0; - unsigned char P0 = 0, P1 = 0; - int lower_half = 0; - - /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on - * either top and bottom or left and right halves */ - CHECK_STREAM (len, 4 + 8); - - P[0] = (*data)[0]; - P[1] = (*data)[1]; - B[0] = (*data)[2]; - B[1] = (*data)[3]; - (*data) += 4; - - if (P[0] <= P[1]) { - - /* need 12 more bytes */ - CHECK_STREAM (len, 12 - 8); - - P[2] = (*data)[0]; - P[3] = (*data)[1]; - B[2] = (*data)[2]; - B[3] = (*data)[3]; - P[4] = (*data)[4]; - P[5] = (*data)[5]; - B[4] = (*data)[6]; - B[5] = (*data)[7]; - P[6] = (*data)[8]; - P[7] = (*data)[9]; - B[6] = (*data)[10]; - B[7] = (*data)[11]; - (*data) += 12; - - flags = - ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | - ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | - ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | - ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); - bitmask = 0x00000001; - lower_half = 0; /* still on top half */ - - for (y = 0; y < 8; ++y) { - - /* time to reload flags? */ - if (y == 4) { - flags = - ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | - ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | - ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | - ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); - bitmask = 0x00000001; - lower_half = 2; - } - - /* get the pixel values ready for this quadrant */ - P0 = P[lower_half + 0]; - P1 = P[lower_half + 1]; - - for (x = 0; x < 8; ++x, bitmask <<= 1) { - if (x == 4) { - P0 = P[lower_half + 4]; - P1 = P[lower_half + 5]; - } - - if (flags & bitmask) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - - } else { - - /* need 8 more bytes */ - B[2] = (*data)[0]; - B[3] = (*data)[1]; - P[2] = (*data)[2]; - P[3] = (*data)[3]; - B[4] = (*data)[4]; - B[5] = (*data)[5]; - B[6] = (*data)[6]; - B[7] = (*data)[7]; - (*data) += 8; - - if (P[2] <= P[3]) { - - /* vertical split; left & right halves are 2-color encoded */ - - flags = - ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | - ((B[0] & 0x0F)) | ((B[4] & 0x0F) << 4) | - ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | - ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); - bitmask = 0x00000001; - - for (y = 0; y < 8; ++y) { - - /* time to reload flags? */ - if (y == 4) { - flags = - ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | - ((B[2] & 0x0F)) | ((B[6] & 0x0F) << 4) | - ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | - ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); - bitmask = 0x00000001; - } - - /* get the pixel values ready for this half */ - P0 = P[0]; - P1 = P[1]; - - for (x = 0; x < 8; ++x, bitmask <<= 1) { - if (x == 4) { - P0 = P[2]; - P1 = P[3]; - } - - if (flags & bitmask) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - - } else { - - /* horizontal split; top & bottom halves are 2-color encoded */ - - P0 = P[0]; - P1 = P[1]; - - for (y = 0; y < 8; ++y) { - - flags = B[y]; - if (y == 4) { - P0 = P[2]; - P1 = P[3]; - } - - for (bitmask = 0x01; bitmask <= 0x80; bitmask <<= 1) { - - if (flags & bitmask) - *frame++ = P1; - else - *frame++ = P0; - } - frame += s->width - 8; - } - } - } - - return 0; -} - -static int -ipvideo_decode_0x9 (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char P[4]; - unsigned char B[4]; - unsigned long flags = 0; - int shifter = 0; - unsigned char pix; - - /* 4-color encoding */ - CHECK_STREAM (len, 4 + 4); - - P[0] = (*data)[0]; - P[1] = (*data)[1]; - P[2] = (*data)[2]; - P[3] = (*data)[3]; - (*data) += 4; - - if ((P[0] <= P[1]) && (P[2] <= P[3])) { - - /* 1 of 4 colors for each pixel, need 16 more bytes */ - CHECK_STREAM (len, 16 - 4); - - for (y = 0; y < 8; ++y) { - /* get the next set of 8 2-bit flags */ - flags = ((*data)[1] << 8) | (*data)[0]; - (*data) += 2; - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { - *frame++ = P[(flags >> shifter) & 0x03]; - } - frame += s->width - 8; - } - - } else if ((P[0] <= P[1]) && (P[2] > P[3])) { - - /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ - B[0] = (*data)[0]; - B[1] = (*data)[1]; - B[2] = (*data)[2]; - B[3] = (*data)[3]; - (*data) += 4; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(frame + x) = pix; - *(frame + x + 1) = pix; - *(frame + s->width + x) = pix; - *(frame + s->width + x + 1) = pix; - } - frame += s->width * 2; - } - - } else if ((P[0] > P[1]) && (P[2] <= P[3])) { - - /* 1 of 4 colors for each 2x1 block, need 8 more bytes */ - CHECK_STREAM (len, 8 - 4); - - for (y = 0; y < 8; ++y) { - /* time to reload flags? */ - if ((y == 0) || (y == 4)) { - B[0] = (*data)[0]; - B[1] = (*data)[1]; - B[2] = (*data)[2]; - B[3] = (*data)[3]; - (*data) += 4; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - } - for (x = 0; x < 8; x += 2, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(frame + x) = pix; - *(frame + x + 1) = pix; - } - frame += s->width; - } - - } else { - - /* 1 of 4 colors for each 1x2 block, need 8 more bytes */ - CHECK_STREAM (len, 8 - 4); - - for (y = 0; y < 8; y += 2) { - /* time to reload flags? */ - if ((y == 0) || (y == 4)) { - B[0] = (*data)[0]; - B[1] = (*data)[1]; - B[2] = (*data)[2]; - B[3] = (*data)[3]; - (*data) += 4; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - } - for (x = 0; x < 8; ++x, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(frame + x) = pix; - *(frame + s->width + x) = pix; - } - frame += s->width * 2; - } - } - - return 0; -} - -static int -ipvideo_decode_0xa (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char P[16]; - unsigned char B[16]; - int flags = 0; - int shifter = 0; - int index; - int split; - int lower_half; - - /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on - * either top and bottom or left and right halves */ - CHECK_STREAM (len, 8 + 16); - - P[0] = (*data)[0]; - P[1] = (*data)[1]; - P[2] = (*data)[2]; - P[3] = (*data)[3]; - B[0] = (*data)[4]; - B[1] = (*data)[5]; - B[2] = (*data)[6]; - B[3] = (*data)[7]; - (*data) += 8; - - if (P[0] <= P[1]) { - - /* 4-color encoding for each quadrant; need 24 more bytes */ - CHECK_STREAM (len, 24 - 16); - - for (y = 4; y < 16; y += 4) { - for (x = y; x < y + 4; ++x) - P[x] = *(*data)++; - for (x = y; x < y + 4; ++x) - B[x] = *(*data)++; - } - - for (y = 0; y < 8; ++y) { - - lower_half = (y >= 4) ? 4 : 0; - flags = (B[y + 8] << 8) | B[y]; - - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { - split = (x >= 4) ? 8 : 0; - index = split + lower_half + ((flags >> shifter) & 0x03); - *frame++ = P[index]; - } - - frame += s->width - 8; - } - - } else { - - /* 4-color encoding for either left and right or top and bottom - * halves; need 16 more bytes */ - - B[4] = (*data)[0]; - B[5] = (*data)[1]; - B[6] = (*data)[2]; - B[7] = (*data)[3]; - P[4] = (*data)[4]; - P[5] = (*data)[5]; - P[6] = (*data)[6]; - P[7] = (*data)[7]; - (*data) += 8; - memcpy (&B[8], *data, 8); - (*data) += 8; - - if (P[4] <= P[5]) { - - /* block is divided into left and right halves */ - for (y = 0; y < 8; ++y) { - - flags = (B[y + 8] << 8) | B[y]; - split = 0; - - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) { - if (x == 4) - split = 4; - *frame++ = P[split + ((flags >> shifter) & 0x03)]; - } - - frame += s->width - 8; - } - - } else { - - /* block is divided into top and bottom halves */ - split = 0; - for (y = 0; y < 8; ++y) { - - flags = (B[y * 2 + 1] << 8) | B[y * 2]; - if (y == 4) - split = 4; - - for (x = 0, shifter = 0; x < 8; ++x, shifter += 2) - *frame++ = P[split + ((flags >> shifter) & 0x03)]; - - frame += s->width - 8; - } - } - } - - return 0; -} - -static int -ipvideo_decode_0xb (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int y; - - /* 64-color encoding (each pixel in block is a different color) */ - CHECK_STREAM (len, 64); - - for (y = 0; y < 8; ++y) { - memcpy (frame, *data, 8); - frame += s->width; - (*data) += 8; - } - - return 0; -} - -static int -ipvideo_decode_0xc (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char pix; - - /* 16-color block encoding: each 2x2 block is a different color */ - CHECK_STREAM (len, 16); - - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2) { - pix = *(*data)++; - *(frame + x) = pix; - *(frame + x + 1) = pix; - *(frame + s->width + x) = pix; - *(frame + s->width + x + 1) = pix; - } - frame += s->width * 2; - } - - return 0; -} - -static int -ipvideo_decode_0xd (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char P[4]; - unsigned char index = 0; - - /* 4-color block encoding: each 4x4 block is a different color */ - CHECK_STREAM (len, 4); - - P[0] = (*data)[0]; - P[1] = (*data)[1]; - P[2] = (*data)[2]; - P[3] = (*data)[3]; - (*data) += 4; - - for (y = 0; y < 8; ++y) { - if (y < 4) - index = 0; - else - index = 2; - - for (x = 0; x < 8; ++x) { - if (x == 4) - ++index; - *frame++ = P[index]; - } - frame += s->width - 8; - } - - return 0; -} - -static int -ipvideo_decode_0xe (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int y; - unsigned char pix; - - /* 1-color encoding: the whole block is 1 solid color */ - CHECK_STREAM (len, 1); - pix = *(*data)++; - - for (y = 0; y < 8; ++y) { - memset (frame, pix, 8); - frame += s->width; - } - - return 0; -} - -static int -ipvideo_decode_0xf (const GstMveDemuxStream * s, unsigned char *frame, - const unsigned char **data, unsigned short *len) -{ - int x, y; - unsigned char P[2]; - - /* dithered encoding */ - CHECK_STREAM (len, 2); - - P[0] = *(*data)++; - P[1] = *(*data)++; - - for (y = 0; y < 8; ++y) { - for (x = 0; x < 4; ++x) { - *frame++ = P[y & 1]; - *frame++ = P[(y & 1) ^ 1]; - } - frame += s->width - 8; - } - - return 0; -} - -int -ipvideo_decode_frame8 (const GstMveDemuxStream * s, const unsigned char *data, - unsigned short len) -{ - int rc = 0; - int x, y, xx, yy; - int index = 0; - unsigned char opcode; - unsigned char *frame; - - frame = s->back_buf1; - - /* decoding is done in 8x8 blocks */ - xx = s->width >> 3; - yy = s->height >> 3; - - for (y = 0; y < yy; ++y) { - for (x = 0; x < xx; ++x) { - /* decoding map contains 4 bits of information per 8x8 block */ - /* bottom nibble first, then top nibble */ - if (index & 1) - opcode = s->code_map[index >> 1] >> 4; - else - opcode = s->code_map[index >> 1] & 0x0F; - ++index; - - /* GST_DEBUG ("block @ (%3d, %3d): encoding 0x%X, data ptr @ %p", - x, y, opcode, data); */ - - switch (opcode) { - case 0x00: - /* copy a block from the previous frame */ - rc = ipvideo_copy_block (s, frame, - frame + (s->back_buf2 - s->back_buf1), 0); - break; - case 0x01: - /* copy block from 2 frames ago; since we switched the back - * buffers we don't actually have to do anything here */ - break; - case 0x02: - rc = ipvideo_decode_0x2 (s, frame, &data, &len); - break; - case 0x03: - rc = ipvideo_decode_0x3 (s, frame, &data, &len); - break; - case 0x04: - rc = ipvideo_decode_0x4 (s, frame, &data, &len); - break; - case 0x05: - rc = ipvideo_decode_0x5 (s, frame, &data, &len); - break; - case 0x06: - /* mystery opcode? skip multiple blocks? */ - GST_WARNING ("encountered unsupported opcode 0x6"); - rc = -1; - break; - case 0x07: - rc = ipvideo_decode_0x7 (s, frame, &data, &len); - break; - case 0x08: - rc = ipvideo_decode_0x8 (s, frame, &data, &len); - break; - case 0x09: - rc = ipvideo_decode_0x9 (s, frame, &data, &len); - break; - case 0x0a: - rc = ipvideo_decode_0xa (s, frame, &data, &len); - break; - case 0x0b: - rc = ipvideo_decode_0xb (s, frame, &data, &len); - break; - case 0x0c: - rc = ipvideo_decode_0xc (s, frame, &data, &len); - break; - case 0x0d: - rc = ipvideo_decode_0xd (s, frame, &data, &len); - break; - case 0x0e: - rc = ipvideo_decode_0xe (s, frame, &data, &len); - break; - case 0x0f: - rc = ipvideo_decode_0xf (s, frame, &data, &len); - break; - } - - if (rc != 0) - return rc; - - frame += 8; - } - frame += 7 * s->width; - } - - return 0; -}