Updated GemRB (patch by Beholder)
This commit is contained in:
@@ -5,7 +5,7 @@ AppName="GemRB"
|
||||
AppFullName=net.sourceforge.gemrb
|
||||
ScreenOrientation=h
|
||||
InhibitSuspend=n
|
||||
AppDataDownloadUrl="Baldur's gate 2 demo|http://sourceforge.net/projects/libsdl-android/files/gemrb/bg2demo.zip/download^!GemRB data(override)|override2.zip^!GemRB data(scripts)|scripts2.zip"
|
||||
AppDataDownloadUrl="Baldur's gate 2 demo|http://sourceforge.net/projects/libsdl-android/files/gemrb/bg2demo.zip/download^!GemRB data(override)|override4.zip^!GemRB data(scripts)|scripts4.zip"
|
||||
SdlVideoResize=y
|
||||
SdlVideoResizeKeepAspect=y
|
||||
NeedDepthBuffer=n
|
||||
@@ -18,16 +18,18 @@ AppUsesJoystick=n
|
||||
AppHandlesJoystickSensitivity=n
|
||||
AppUsesMultitouch=n
|
||||
NonBlockingSwapBuffers=n
|
||||
RedefinedKeys="LCTRL c p o e"
|
||||
RedefinedKeys="LCTRL c NO_REMAP NO_REMAP e"
|
||||
AppTouchscreenKeyboardKeysAmount=0
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
RedefinedKeysScreenKb="LCTRL c p o e"
|
||||
RedefinedKeysScreenKb="LCTRL c NO_REMAP NO_REMAP e"
|
||||
StartupMenuButtonTimeout=2000
|
||||
HiddenMenuOptions=''
|
||||
MultiABI=y
|
||||
AppVersionCode=0641
|
||||
AppVersionName="0.6.4.1"
|
||||
AppVersionCode=0643
|
||||
AppVersionName="0.6.4.3"
|
||||
CompiledLibraries="sdl_mixer ogg vorbis openal png python"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-fexceptions -finline-functions -O3 -DSTATIC_LINK=Yes -DHAVE_SNPRINTF -DTOUCHSCREEN'
|
||||
AppCflags='-fexceptions -finline-functions -O3 -DSTATIC_LINK=Yes -DHAVE_SNPRINTF'
|
||||
AppLdflags=''
|
||||
AppSubdirsBuild=''
|
||||
AppCmdline='GemRB'
|
||||
|
||||
BIN
project/jni/application/gemrb/AndroidData/override4.zip
Normal file
BIN
project/jni/application/gemrb/AndroidData/override4.zip
Normal file
Binary file not shown.
BIN
project/jni/application/gemrb/AndroidData/scripts4.zip
Normal file
BIN
project/jni/application/gemrb/AndroidData/scripts4.zip
Normal file
Binary file not shown.
@@ -22,10 +22,14 @@
|
||||
|
||||
#include "win32def.h" // logging
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "Interface.h"
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
//this supposed to convince SDL to work on OS/X
|
||||
//WARNING: commenting this out will cause SDL 1.2.x to crash
|
||||
@@ -35,28 +39,43 @@
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <SDL/SDL.h>
|
||||
#include "Audio.h"
|
||||
#include "audio.h"
|
||||
|
||||
// pause audio playing if app goes in background
|
||||
static void appPutToBackground()
|
||||
{
|
||||
core->GetAudioDrv()->Pause();
|
||||
core->GetAudioDrv()->Pause();
|
||||
}
|
||||
// resume audio playing if app return to foreground
|
||||
static void appPutToForeground()
|
||||
{
|
||||
core->GetAudioDrv()->Resume();
|
||||
core->GetAudioDrv()->Resume();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef M_TRIM_THRESHOLD
|
||||
// Prevent fragmentation of the heap by malloc (glibc).
|
||||
//
|
||||
// The default threshold is 128*1024, which can result in a large memory usage
|
||||
// due to fragmentation since we use a lot of small objects. On the other hand
|
||||
// if the threshold is too low, free() starts to permanently ask the kernel
|
||||
// about shrinking the heap.
|
||||
#ifdef HAVE_UNISTD_H
|
||||
int pagesize = sysconf(_SC_PAGESIZE);
|
||||
#else
|
||||
int pagesize = 4*1024;
|
||||
#endif
|
||||
mallopt(M_TRIM_THRESHOLD, 5*pagesize);
|
||||
#endif
|
||||
|
||||
Interface::SanityCheck(VERSION_GEMRB);
|
||||
core = new Interface( argc, argv );
|
||||
if (core->Init() == GEM_ERROR) {
|
||||
delete( core );
|
||||
printf("Press enter to continue...");
|
||||
print("Press enter to continue...");
|
||||
textcolor(DEFAULT);
|
||||
getc(stdin);
|
||||
return -1;
|
||||
|
||||
@@ -22,14 +22,15 @@
|
||||
#define ACTORMGR_H
|
||||
|
||||
#include "Plugin.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
#include "System/DataStream.h"
|
||||
|
||||
class Actor;
|
||||
class DataStream;
|
||||
|
||||
class GEM_EXPORT ActorMgr : public Plugin {
|
||||
public:
|
||||
ActorMgr(void);
|
||||
virtual ~ActorMgr(void);
|
||||
virtual bool Open(DataStream* stream, bool autoFree = true) = 0;
|
||||
virtual bool Open(DataStream* stream) = 0;
|
||||
virtual Actor* GetActor(unsigned char is_in_party) = 0;
|
||||
|
||||
//returns saved size, updates internal offsets before save
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "Game.h"
|
||||
#include "Interface.h"
|
||||
#include "Map.h"
|
||||
#include "Sprite2D.h"
|
||||
#include "Video.h"
|
||||
|
||||
Animation::Animation(int count)
|
||||
@@ -71,8 +72,7 @@ void Animation::SetPos(unsigned int index)
|
||||
void Animation::AddFrame(Sprite2D* frame, unsigned int index)
|
||||
{
|
||||
if (index>=indicesCount) {
|
||||
printf("You tried to write past a buffer in animation, BAD!\n");
|
||||
abort();
|
||||
error("Animation", "You tried to write past a buffer in animation, BAD!\n");
|
||||
}
|
||||
core->GetVideoDriver()->FreeSprite(frames[index]);
|
||||
frames[index]=frame;
|
||||
@@ -107,13 +107,13 @@ unsigned int Animation::GetCurrentFrame() const
|
||||
Sprite2D* Animation::LastFrame(void)
|
||||
{
|
||||
if (!Flags&A_ANI_ACTIVE) {
|
||||
printf("Frame fetched while animation is inactive!\n");
|
||||
print("Frame fetched while animation is inactive!\n");
|
||||
return NULL;
|
||||
}
|
||||
if (gameAnimation) {
|
||||
starttime = core->GetGame()->Ticks;
|
||||
} else {
|
||||
GetTime( starttime );
|
||||
starttime = GetTickCount();
|
||||
}
|
||||
Sprite2D* ret;
|
||||
if (playReversed)
|
||||
@@ -126,14 +126,14 @@ Sprite2D* Animation::LastFrame(void)
|
||||
Sprite2D* Animation::NextFrame(void)
|
||||
{
|
||||
if (!Flags&A_ANI_ACTIVE) {
|
||||
printf("Frame fetched while animation is inactive!\n");
|
||||
print("Frame fetched while animation is inactive!\n");
|
||||
return NULL;
|
||||
}
|
||||
if (starttime == 0) {
|
||||
if (gameAnimation) {
|
||||
starttime = core->GetGame()->Ticks;
|
||||
} else {
|
||||
GetTime( starttime );
|
||||
starttime = GetTickCount();
|
||||
}
|
||||
}
|
||||
Sprite2D* ret;
|
||||
@@ -149,7 +149,7 @@ Sprite2D* Animation::NextFrame(void)
|
||||
if (gameAnimation) {
|
||||
time = core->GetGame()->Ticks;
|
||||
} else {
|
||||
GetTime(time);
|
||||
time = GetTickCount();
|
||||
}
|
||||
|
||||
//it could be that we skip more than one frame in case of slow rendering
|
||||
@@ -180,7 +180,7 @@ Sprite2D* Animation::NextFrame(void)
|
||||
Sprite2D* Animation::GetSyncedNextFrame(Animation* master)
|
||||
{
|
||||
if (!Flags&A_ANI_ACTIVE) {
|
||||
printf("Frame fetched while animation is inactive!\n");
|
||||
print("Frame fetched while animation is inactive!\n");
|
||||
return NULL;
|
||||
}
|
||||
Sprite2D* ret;
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
#include "globals.h"
|
||||
|
||||
#include "Region.h"
|
||||
#include "Sprite2D.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Sprite2D;
|
||||
|
||||
class GEM_EXPORT Animation {
|
||||
private:
|
||||
Sprite2D **frames;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "win32def.h"
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Sprite2D.h"
|
||||
#include "Video.h"
|
||||
|
||||
AnimationFactory::AnimationFactory(const char* ResRef)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "globals.h"
|
||||
|
||||
#include "Animation.h"
|
||||
#include "AnimStructures.h"
|
||||
#include "FactoryObject.h"
|
||||
|
||||
class GEM_EXPORT AnimationFactory : public FactoryObject {
|
||||
|
||||
@@ -25,14 +25,15 @@
|
||||
|
||||
#include "Animation.h"
|
||||
#include "AnimationFactory.h"
|
||||
#include "Font.h"
|
||||
#include "Plugin.h"
|
||||
|
||||
class Font;
|
||||
|
||||
class GEM_EXPORT AnimationMgr : public Plugin {
|
||||
public:
|
||||
AnimationMgr(void);
|
||||
virtual ~AnimationMgr(void);
|
||||
virtual bool Open(DataStream* stream, bool autoFree = true) = 0;
|
||||
virtual bool Open(DataStream* stream) = 0;
|
||||
virtual int GetCycleSize(unsigned char Cycle) = 0;
|
||||
virtual AnimationFactory* GetAnimationFactory(const char* ResRef,
|
||||
unsigned char mode = IE_NORMAL) = 0;
|
||||
|
||||
@@ -29,12 +29,10 @@ class GEM_EXPORT ArchiveImporter : public Plugin {
|
||||
public:
|
||||
ArchiveImporter(void);
|
||||
virtual ~ArchiveImporter(void);
|
||||
virtual int OpenArchive(const char* filename) = 0;
|
||||
virtual int CreateArchive(DataStream *stream) = 0;
|
||||
//decompressing a .sav file similar to CBF
|
||||
virtual int DecompressSaveGame(DataStream *compressed) = 0;
|
||||
virtual int AddToSaveGame(DataStream *str, DataStream *uncompressed) = 0;
|
||||
virtual DataStream* GetStream(unsigned long Resource, unsigned long Type) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,92 @@
|
||||
ADD_DEFINITIONS(-DGEM_BUILD_DLL)
|
||||
|
||||
FILE(GLOB gemrb_core_LIB_SRCS "*.cpp"
|
||||
FILE(GLOB gemrb_core_LIB_SRCS
|
||||
ActorMgr.cpp
|
||||
Ambient.cpp
|
||||
AmbientMgr.cpp
|
||||
Animation.cpp
|
||||
AnimationFactory.cpp
|
||||
AnimationMgr.cpp
|
||||
ArchiveImporter.cpp
|
||||
Audio.cpp
|
||||
Bitmap.cpp
|
||||
Cache.cpp
|
||||
Calendar.cpp
|
||||
Callback.cpp
|
||||
CharAnimations.cpp
|
||||
Compressor.cpp
|
||||
ControlAnimation.cpp
|
||||
Core.cpp
|
||||
DataFileMgr.cpp
|
||||
Dialog.cpp
|
||||
DialogHandler.cpp
|
||||
DialogMgr.cpp
|
||||
DisplayMessage.cpp
|
||||
EffectMgr.cpp
|
||||
EffectQueue.cpp
|
||||
Factory.cpp
|
||||
FactoryObject.cpp
|
||||
FileCache.cpp
|
||||
Font.cpp
|
||||
Game.cpp
|
||||
GameData.cpp
|
||||
GlobalTimer.cpp
|
||||
Image.cpp
|
||||
ImageFactory.cpp
|
||||
ImageMgr.cpp
|
||||
ImageWriter.cpp
|
||||
IndexedArchive.cpp
|
||||
IniSpawn.cpp
|
||||
Interface.cpp
|
||||
Inventory.cpp
|
||||
Item.cpp
|
||||
ItemMgr.cpp
|
||||
KeyMap.cpp
|
||||
LRUCache.cpp
|
||||
Map.cpp
|
||||
MapMgr.cpp
|
||||
MoviePlayer.cpp
|
||||
MusicMgr.cpp
|
||||
Palette.cpp
|
||||
PalettedImageMgr.cpp
|
||||
Particles.cpp
|
||||
Plugin.cpp
|
||||
PluginLoader.cpp
|
||||
PluginMgr.cpp
|
||||
Polygon.cpp
|
||||
Projectile.cpp
|
||||
ProjectileMgr.cpp
|
||||
ProjectileServer.cpp
|
||||
Region.cpp
|
||||
Resource.cpp
|
||||
ResourceDesc.cpp
|
||||
ResourceManager.cpp
|
||||
ResourceSource.cpp
|
||||
SaveGameIterator.cpp
|
||||
SaveGameMgr.cpp
|
||||
ScriptEngine.cpp
|
||||
ScriptedAnimation.cpp
|
||||
SoundMgr.cpp
|
||||
Spell.cpp
|
||||
SpellMgr.cpp
|
||||
Spellbook.cpp
|
||||
Sprite2D.cpp
|
||||
SpriteCover.cpp
|
||||
Store.cpp
|
||||
StoreMgr.cpp
|
||||
StringMgr.cpp
|
||||
SymbolMgr.cpp
|
||||
TableMgr.cpp
|
||||
Tile.cpp
|
||||
TileMap.cpp
|
||||
TileMapMgr.cpp
|
||||
TileOverlay.cpp
|
||||
TileSetMgr.cpp
|
||||
Variables.cpp
|
||||
Video.cpp
|
||||
WindowMgr.cpp
|
||||
WorldMap.cpp
|
||||
WorldMapMgr.cpp
|
||||
GameScript/Actions.cpp
|
||||
GameScript/GSUtils.cpp
|
||||
GameScript/GameScript.cpp
|
||||
@@ -27,12 +113,13 @@ FILE(GLOB gemrb_core_LIB_SRCS "*.cpp"
|
||||
Scriptable/InfoPoint.cpp
|
||||
Scriptable/Scriptable.cpp
|
||||
Scriptable/PCStatStruct.cpp
|
||||
System/CachedFileStream.cpp
|
||||
System/DataStream.cpp
|
||||
System/FileStream.cpp
|
||||
System/MemoryStream.cpp
|
||||
System/Logging.cpp
|
||||
System/SlicedStream.cpp
|
||||
System/String.cpp
|
||||
System/VFS.cpp
|
||||
System/snprintf.cpp
|
||||
)
|
||||
|
||||
if (STATIC_LINK)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Cache.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <ctype.h>
|
||||
|
||||
// private inlines
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "win32def.h"
|
||||
|
||||
#include "AnimationFactory.h"
|
||||
#include "DataFileMgr.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "ImageMgr.h"
|
||||
@@ -448,8 +450,7 @@ void CharAnimations::InitAvatarsTable()
|
||||
{
|
||||
AutoTable Avatars("avatars");
|
||||
if (!Avatars) {
|
||||
printMessage("CharAnimations", "A critical animation file is missing!\n", LIGHT_RED);
|
||||
abort();
|
||||
error("CharAnimations", "A critical animation file is missing!\n");
|
||||
}
|
||||
AvatarTable = (AvatarStruct *) calloc ( AvatarsCount = Avatars->GetRowCount(), sizeof(AvatarStruct) );
|
||||
int i=AvatarsCount;
|
||||
@@ -511,8 +512,8 @@ void CharAnimations::InitAvatarsTable()
|
||||
valid_number(blood->QueryField(i,1), (long &)rmin);
|
||||
valid_number(blood->QueryField(i,2), (long &)rmax);
|
||||
if (value>255 || rmin>0xffff || rmax>0xffff) {
|
||||
printMessage("CharAnimations", "bloodclr entry:", LIGHT_RED);
|
||||
printf("%02x %04x-%04x ", (unsigned int) value, (unsigned int) rmin, (unsigned int) rmax);
|
||||
printMessage("CharAnimations", "bloodclr entry: %02x %04x-%04x ", LIGHT_RED,
|
||||
(unsigned int) value, (unsigned int) rmin, (unsigned int) rmax);
|
||||
printStatus("Invalid value!", LIGHT_RED);
|
||||
continue;
|
||||
}
|
||||
@@ -609,8 +610,7 @@ CharAnimations::CharAnimations(unsigned int AnimID, ieDword ArmourLevel)
|
||||
}
|
||||
}
|
||||
ResRef[0]=0;
|
||||
printMessage("CharAnimations", " ", LIGHT_RED);
|
||||
printf("Invalid or nonexistent avatar entry:%04X\n", AnimID);
|
||||
printMessage("CharAnimations", "Invalid or nonexistent avatar entry:%04X\n", LIGHT_RED, AnimID);
|
||||
}
|
||||
|
||||
//we have to drop them when armourlevel changes
|
||||
@@ -782,8 +782,7 @@ WSW 003 | 013 ESE
|
||||
Animation** CharAnimations::GetAnimation(unsigned char Stance, unsigned char Orient)
|
||||
{
|
||||
if (StanceID>=MAX_ANIMS) {
|
||||
printf("Illegal stance ID\n");
|
||||
abort();
|
||||
error("CharAnimation", "Illegal stance ID\n");
|
||||
}
|
||||
|
||||
//for paletted dragon animations, we need the stance id
|
||||
@@ -864,7 +863,7 @@ Animation** CharAnimations::GetAnimation(unsigned char Stance, unsigned char Ori
|
||||
autoSwitchOnEnd = true;
|
||||
break;
|
||||
default:
|
||||
printf ("Invalid Stance: %d\n", StanceID);
|
||||
print ("Invalid Stance: %d\n", StanceID);
|
||||
break;
|
||||
}
|
||||
Animation** anims = Anims[StanceID][Orient];
|
||||
@@ -931,10 +930,8 @@ Animation** CharAnimations::GetAnimation(unsigned char Stance, unsigned char Ori
|
||||
|
||||
if (!af) {
|
||||
if (part < actorPartCount) {
|
||||
char warnbuf[200];
|
||||
snprintf(warnbuf, 200,
|
||||
"Couldn't create animationfactory: %s (%04x)\n", NewResRef, GetAnimationID());
|
||||
printMessage("CharAnimations",warnbuf,LIGHT_RED);
|
||||
printMessage("CharAnimations", "Couldn't create animationfactory: %s (%04x)\n",
|
||||
LIGHT_RED, NewResRef, GetAnimationID());;
|
||||
for (int i = 0; i < part; ++i)
|
||||
delete anims[i];
|
||||
delete[] anims;
|
||||
@@ -951,11 +948,8 @@ Animation** CharAnimations::GetAnimation(unsigned char Stance, unsigned char Ori
|
||||
|
||||
if (!a) {
|
||||
if (part < actorPartCount) {
|
||||
char warnbuf[200];
|
||||
snprintf(warnbuf, 200,
|
||||
"Couldn't load animation: %s, cycle %d\n",
|
||||
printMessage("CharAnimations", "Couldn't load animation: %s, cycle %d\n", LIGHT_RED,
|
||||
NewResRef, Cycle);
|
||||
printMessage("CharAnimations",warnbuf,LIGHT_RED);
|
||||
for (int i = 0; i < part; ++i)
|
||||
delete anims[i];
|
||||
delete[] anims;
|
||||
@@ -1100,8 +1094,7 @@ Animation** CharAnimations::GetAnimation(unsigned char Stance, unsigned char Ori
|
||||
Anims[StanceID][0] = anims;
|
||||
break;
|
||||
default:
|
||||
printMessage("CharAnimations","Unknown animation type\n",LIGHT_RED);
|
||||
abort();
|
||||
error("CharAnimations", "Unknown animation type\n");
|
||||
}
|
||||
delete equipdat;
|
||||
|
||||
@@ -1115,7 +1108,6 @@ void CharAnimations::GetAnimResRef(unsigned char StanceID,
|
||||
char* NewResRef, unsigned char& Cycle,
|
||||
int Part, EquipResRefData*& EquipData)
|
||||
{
|
||||
char tmp[256];
|
||||
EquipData = 0;
|
||||
Orient &= 15;
|
||||
switch (GetAnimType()) {
|
||||
@@ -1203,9 +1195,7 @@ void CharAnimations::GetAnimResRef(unsigned char StanceID,
|
||||
strnlwrcpy(NewResRef, AvatarTable[AvatarsRowNum].Prefixes[Part], 8);
|
||||
break;
|
||||
default:
|
||||
sprintf (tmp,"Unknown animation type in avatars.2da row: %d\n", AvatarsRowNum);
|
||||
printMessage ("CharAnimations",tmp, LIGHT_RED);
|
||||
abort();
|
||||
error("CharAnimations", "Unknown animation type in avatars.2da row: %d\n", AvatarsRowNum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1224,8 +1214,7 @@ void CharAnimations::GetEquipmentResRef(const char* equipRef, bool offhand,
|
||||
GetMHREquipmentRef( ResRef, Cycle, equipRef, offhand, equip );
|
||||
break;
|
||||
default:
|
||||
printMessage ("CharAnimations", "Unsupported animation type for equipment animation.\n", LIGHT_RED);
|
||||
abort();
|
||||
error("CharAnimations", "Unsupported animation type for equipment animation.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1379,9 +1368,12 @@ void CharAnimations::AddVHR2Suffix(char* ResRef, unsigned char StanceID,
|
||||
case IE_ANI_WALK:
|
||||
strcat( ResRef, "g11" );
|
||||
break;
|
||||
|
||||
case IE_ANI_HIDE:
|
||||
strcat( ResRef, "g22" );
|
||||
break;
|
||||
default:
|
||||
printf("VHR2 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "VHR2 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1459,8 +1451,7 @@ void CharAnimations::AddVHR3Suffix(char* ResRef, unsigned char StanceID,
|
||||
strcat( ResRef, "g11" );
|
||||
break;
|
||||
default:
|
||||
printf("VHR3 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "VHR3 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1521,8 +1512,7 @@ void CharAnimations::AddFFSuffix(char* ResRef, unsigned char StanceID,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Four frames Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "Four frames Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -1663,8 +1653,7 @@ void CharAnimations::AddVHRSuffix(char* ResRef, unsigned char StanceID,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("VHR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "VHR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
EquipData->Cycle = Cycle;
|
||||
@@ -1732,13 +1721,13 @@ void CharAnimations::AddSixSuffix(char* ResRef, unsigned char StanceID,
|
||||
break;
|
||||
|
||||
case IE_ANI_TWITCH:
|
||||
case IE_ANI_SLEEP:
|
||||
strcat( ResRef, "g2" );
|
||||
Cycle = 64 + Orient;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Six Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "Six Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -1787,8 +1776,7 @@ void CharAnimations::AddLR2Suffix(char* ResRef, unsigned char StanceID,
|
||||
Cycle = 32 + Orient;
|
||||
break;
|
||||
default:
|
||||
printf("LR2 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "LR2 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
if (Orient>=4) {
|
||||
@@ -1910,8 +1898,7 @@ void CharAnimations::AddMHRSuffix(char* ResRef, unsigned char StanceID,
|
||||
Cycle = Orient;
|
||||
break;
|
||||
default:
|
||||
printf("MHR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "MHR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
if (Orient>=5) {
|
||||
@@ -2018,14 +2005,14 @@ void CharAnimations::AddLRSuffix2( char* ResRef, unsigned char StanceID,
|
||||
Cycle = 32 + Orient / 2;
|
||||
break;
|
||||
case IE_ANI_SLEEP:
|
||||
case IE_ANI_HIDE:
|
||||
case IE_ANI_TWITCH:
|
||||
strcat( ResRef, "g1" );
|
||||
strcpy( EquipData->Suffix, "g1" );
|
||||
Cycle = 40 + Orient / 2;
|
||||
break;
|
||||
default:
|
||||
printf("LRSuffix2 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "LRSuffix2 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
if (Orient > 9) {
|
||||
@@ -2101,8 +2088,7 @@ void CharAnimations::AddLRSuffix( char* ResRef, unsigned char StanceID,
|
||||
Cycle = 40 + Orient / 2;
|
||||
break;
|
||||
default:
|
||||
printf("LR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "LR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
if (Orient > 9) {
|
||||
@@ -2175,8 +2161,7 @@ void CharAnimations::AddLR3Suffix( char* ResRef, unsigned char StanceID,
|
||||
Cycle = 24 + Orient / 2;
|
||||
break;
|
||||
default:
|
||||
printf("LR3 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "LR3 Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
if (Orient > 9) {
|
||||
@@ -2250,8 +2235,7 @@ void CharAnimations::AddMMR2Suffix(char* ResRef, unsigned char StanceID,
|
||||
Cycle = ( Orient / 2 );
|
||||
break;
|
||||
default:
|
||||
printf("MMR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "MMR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
if (Orient > 9) {
|
||||
@@ -2337,8 +2321,7 @@ void CharAnimations::AddMMRSuffix(char* ResRef, unsigned char StanceID,
|
||||
Cycle = ( Orient / 2 );
|
||||
break;
|
||||
default:
|
||||
printf("MMR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
abort();
|
||||
error("CharAnimation", "MMR Animation: unhandled stance: %s %d\n", ResRef, StanceID);
|
||||
break;
|
||||
}
|
||||
if (Orient > 9) {
|
||||
|
||||
@@ -29,9 +29,3 @@ Compressor::Compressor(void)
|
||||
Compressor::~Compressor(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Initialization Function. Returns FALSE if there was an error during initialization, else returns TRUE.
|
||||
int Compressor::Init(void)
|
||||
{
|
||||
return GEM_OK;
|
||||
}
|
||||
|
||||
@@ -24,16 +24,12 @@
|
||||
#include "Plugin.h"
|
||||
#include "System/DataStream.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
class GEM_EXPORT Compressor : public Plugin {
|
||||
public:
|
||||
Compressor(void);
|
||||
virtual ~Compressor(void);
|
||||
/** Initialization Function. Returns FALSE if there was an error during initialization, else returns TRUE. */
|
||||
virtual int Init(void);
|
||||
/** decompresses a datastream (memory or file) to a FILE * stream */
|
||||
virtual int Decompress(FILE* dest, DataStream* source, unsigned int size_guess = 0) const = 0;
|
||||
virtual int Decompress(DataStream* dest, DataStream* source, unsigned int size_guess = 0) const = 0;
|
||||
/** compresses a datastream (memory or file) to another DataStream */
|
||||
virtual int Compress(DataStream *dest, DataStream* source) const = 0;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
|
||||
#include "win32def.h"
|
||||
|
||||
#include "AnimationFactory.h"
|
||||
#include "GameData.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "Interface.h"
|
||||
#include "Palette.h" /* needed only for paperdoll palettes */
|
||||
#include "Video.h" /* needed only for paperdoll palettes */
|
||||
@@ -45,6 +47,7 @@ ControlAnimation::ControlAnimation(Control* ctl, const ieResRef ResRef, int Cycl
|
||||
control = ctl;
|
||||
control->animation = this;
|
||||
has_palette = false;
|
||||
is_blended = false;
|
||||
}
|
||||
|
||||
//freeing the bitmaps only once, but using an intelligent algorithm
|
||||
@@ -108,6 +111,7 @@ void ControlAnimation::UpdateAnimation(void)
|
||||
//stopping at end frame
|
||||
if (control->Flags & IE_GUI_BUTTON_PLAYONCE) {
|
||||
core->timer->RemoveAnimation( this );
|
||||
control->SetAnimPicture( NULL );
|
||||
return;
|
||||
}
|
||||
anim_phase = 0;
|
||||
@@ -122,8 +126,18 @@ void ControlAnimation::UpdateAnimation(void)
|
||||
if (has_palette) {
|
||||
Palette* palette = pic->GetPalette();
|
||||
palette->SetupPaperdollColours(colors, 0);
|
||||
if (is_blended) {
|
||||
palette->CreateShadedAlphaChannel();
|
||||
}
|
||||
pic->SetPalette(palette);
|
||||
palette->Release();
|
||||
} else {
|
||||
if (is_blended) {
|
||||
Palette* palette = pic->GetPalette();
|
||||
palette->CreateShadedAlphaChannel();
|
||||
pic->SetPalette(palette);
|
||||
palette->Release();
|
||||
}
|
||||
}
|
||||
|
||||
control->SetAnimPicture( pic );
|
||||
@@ -136,3 +150,7 @@ void ControlAnimation::SetPaletteGradients(ieDword *col)
|
||||
has_palette = true;
|
||||
}
|
||||
|
||||
void ControlAnimation::SetBlend(bool b)
|
||||
{
|
||||
is_blended = b;
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
|
||||
#include "RGBAColor.h"
|
||||
#include "exports.h"
|
||||
|
||||
#include "AnimationFactory.h"
|
||||
#include "Sprite2D.h"
|
||||
#include "GUI/Control.h"
|
||||
#include "globals.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class AnimationFactory;
|
||||
class Control;
|
||||
|
||||
class GEM_EXPORT ControlAnimation {
|
||||
private:
|
||||
AnimationFactory* bam;
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
unsigned int frame;
|
||||
unsigned int anim_phase;
|
||||
bool has_palette;
|
||||
bool is_blended;
|
||||
ieDword colors[8];
|
||||
public:
|
||||
ControlAnimation(Control* ctl, const ieResRef ResRef, int Cycle = 0);
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
//report if the current resource is the same as descripted by the params
|
||||
bool SameResource(const ieResRef ResRef, int Cycle);
|
||||
void SetPaletteGradients(ieDword *col);
|
||||
void SetBlend(bool b);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -48,65 +48,6 @@ BOOL WINAPI DllEntryPoint(HINSTANCE /*hinstDLL*/, DWORD /*fdwReason*/,
|
||||
|
||||
//// Globally used functions
|
||||
|
||||
ieByte pl_uppercase[256];
|
||||
ieByte pl_lowercase[256];
|
||||
|
||||
// these 3 functions will copy a string to a zero terminated string with a maximum length
|
||||
void strnlwrcpy(char *dest, const char *source, int count)
|
||||
{
|
||||
while(count--) {
|
||||
*dest++ = pl_lowercase[(ieByte) *source];
|
||||
if(!*source++) {
|
||||
while(count--) *dest++=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*dest=0;
|
||||
}
|
||||
|
||||
void strnuprcpy(char* dest, const char *source, int count)
|
||||
{
|
||||
while(count--) {
|
||||
*dest++ = pl_uppercase[(ieByte) *source];
|
||||
if(!*source++) {
|
||||
while(count--) *dest++=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*dest=0;
|
||||
}
|
||||
|
||||
// this one also filters spaces, used to copy variables
|
||||
void strnspccpy(char* dest, const char *source, int count)
|
||||
{
|
||||
memset(dest,0,count);
|
||||
while(count--) {
|
||||
char c = pl_uppercase[(ieByte) *source];
|
||||
if (c!=' ') {
|
||||
*dest++=c;
|
||||
}
|
||||
if(!*source++) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
int strnlen(const char* string, int maxlen)
|
||||
{
|
||||
if (!string) {
|
||||
return -1;
|
||||
}
|
||||
int i = 0;
|
||||
while (maxlen-- > 0) {
|
||||
if (!string[i])
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
#endif // ! HAVE_STRNLEN
|
||||
|
||||
static const unsigned char orientations[25]={
|
||||
6,7,8,9,10,
|
||||
5,6,8,10,11,
|
||||
@@ -269,55 +210,3 @@ int EARelation(Scriptable* Owner, Actor* target)
|
||||
|
||||
return EAR_NEUTRAL;
|
||||
}
|
||||
|
||||
/** Returns the length of string (up to a delimiter) */
|
||||
GEM_EXPORT int strlench(const char* string, char ch)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; string[i] && string[i] != ch; i++)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
//// Compatibility functions
|
||||
#ifndef HAVE_STRNDUP
|
||||
GEM_EXPORT char* strndup(const char* s, size_t l)
|
||||
{
|
||||
size_t len = strlen( s );
|
||||
if (len < l) {
|
||||
l = len;
|
||||
}
|
||||
char* string = ( char* ) malloc( l + 1 );
|
||||
strncpy( string, s, l );
|
||||
string[l] = 0;
|
||||
return string;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#else
|
||||
|
||||
char* strupr(char* string)
|
||||
{
|
||||
char* s;
|
||||
if (string) {
|
||||
for (s = string; *s; ++s)
|
||||
*s = toupper( *s );
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
char* strlwr(char* string)
|
||||
{
|
||||
char* s;
|
||||
if (string) {
|
||||
for (s = string; *s; ++s)
|
||||
*s = tolower( *s );
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
#endif // ! WIN32
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class GEM_EXPORT DataFileMgr : public Plugin {
|
||||
public:
|
||||
DataFileMgr(void);
|
||||
virtual ~DataFileMgr(void);
|
||||
virtual bool Open(DataStream* stream, bool autoFree = false) = 0;
|
||||
virtual bool Open(DataStream* stream) = 0;
|
||||
virtual int GetTagsCount() const = 0;
|
||||
virtual const char* GetTagNameByIndex(int index) const = 0;
|
||||
virtual int GetKeysCount(const char* Tag) const = 0;
|
||||
|
||||
@@ -25,10 +25,14 @@
|
||||
#include "DisplayMessage.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "ScriptEngine.h"
|
||||
#include "TableMgr.h"
|
||||
#include "Video.h"
|
||||
#include "GameScript/GameScript.h"
|
||||
#include "GUI/GameControl.h"
|
||||
#include "GUI/TextArea.h"
|
||||
|
||||
//translate section values (journal, solved, unsolved, user)
|
||||
static int sectionMap[4]={4,1,2,0};
|
||||
@@ -56,7 +60,7 @@ DialogHandler::~DialogHandler(void)
|
||||
}
|
||||
|
||||
//Try to start dialogue between two actors (one of them could be inanimate)
|
||||
int DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgref)
|
||||
bool DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgref)
|
||||
{
|
||||
if (dlg) {
|
||||
delete dlg;
|
||||
@@ -64,13 +68,12 @@ int DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgr
|
||||
}
|
||||
|
||||
PluginHolder<DialogMgr> dm(IE_DLG_CLASS_ID);
|
||||
dm->Open( gamedata->GetResource( dlgref, IE_DLG_CLASS_ID ), true );
|
||||
dm->Open(gamedata->GetResource(dlgref, IE_DLG_CLASS_ID));
|
||||
dlg = dm->GetDialog();
|
||||
|
||||
if (!dlg) {
|
||||
printMessage("GameControl", " ", LIGHT_RED);
|
||||
printf( "Cannot start dialog: %s\n", dlgref );
|
||||
return -1;
|
||||
printMessage("GameControl", "Cannot start dialog: %s\n", LIGHT_RED, dlgref);
|
||||
return false;
|
||||
}
|
||||
|
||||
strnlwrcpy(dlg->ResRef, dlgref, 8); //this isn't handled by GetDialog???
|
||||
@@ -85,8 +88,9 @@ int DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgr
|
||||
if (!originalTargetID) originalTargetID = tgt->GetGlobalID();
|
||||
if (tgt->Type==ST_ACTOR) {
|
||||
Actor *tar = (Actor *) tgt;
|
||||
spk->LastTalkedTo=targetID;
|
||||
tar->LastTalkedTo=speakerID;
|
||||
// TODO: verify
|
||||
spk->LastTalker=targetID;
|
||||
tar->LastTalker=speakerID;
|
||||
tar->SetCircleSize();
|
||||
}
|
||||
if (oldTarget) oldTarget->SetCircleSize();
|
||||
@@ -94,16 +98,16 @@ int DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgr
|
||||
GameControl *gc = core->GetGameControl();
|
||||
|
||||
if (!gc)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
//check if we are already in dialog
|
||||
if (gc->GetDialogueFlags()&DF_IN_DIALOG) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int si = dlg->FindFirstState( tgt );
|
||||
if (si < 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
//we need GUI for dialogs
|
||||
@@ -134,7 +138,7 @@ int DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgr
|
||||
//core->GetGame()->SetControlStatus(CS_HIDEGUI, BM_NAND);
|
||||
//core->GetGame()->SetControlStatus(CS_DIALOG, BM_OR);
|
||||
//core->SetEventFlag(EF_PORTRAIT);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*try to break will only try to break it, false means unconditional stop*/
|
||||
@@ -348,16 +352,15 @@ void DialogHandler::DialogChoose(unsigned int choose)
|
||||
// we have to make a backup, tr->Dialog is freed
|
||||
ieResRef tmpresref;
|
||||
strnlwrcpy(tmpresref,tr->Dialog, 8);
|
||||
if (target->GetInternalFlag()&IF_NOINT) {
|
||||
/*if (target->GetInternalFlag()&IF_NOINT) {
|
||||
// this whole check moved out of InitDialog by fuzzie, see comments
|
||||
// for the IF_NOINT check in BeginDialog
|
||||
displaymsg->DisplayConstantString(STR_TARGETBUSY,0xff0000);
|
||||
ta->SetMinRow( false );
|
||||
EndDialog();
|
||||
return;
|
||||
}
|
||||
int ret = InitDialog( speaker, target, tmpresref);
|
||||
if (ret<0) {
|
||||
}*/
|
||||
if (!InitDialog( speaker, target, tmpresref)) {
|
||||
// error was displayed by InitDialog
|
||||
ta->SetMinRow( false );
|
||||
EndDialog();
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
Scriptable *GetTarget();
|
||||
Actor *GetSpeaker();
|
||||
|
||||
int InitDialog(Scriptable* speaker, Scriptable* target, const char* dlgref);
|
||||
bool InitDialog(Scriptable* speaker, Scriptable* target, const char* dlgref);
|
||||
void EndDialog(bool try_to_break=false);
|
||||
void DialogChoose(unsigned int choose);
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ class GEM_EXPORT DialogMgr : public Plugin {
|
||||
public:
|
||||
DialogMgr(void);
|
||||
virtual ~DialogMgr(void);
|
||||
virtual bool Open(DataStream* stream, bool autoFree = true) = 0;
|
||||
virtual bool Open(DataStream* stream) = 0;
|
||||
virtual Dialog* GetDialog() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "TableMgr.h"
|
||||
#include "GUI/Label.h"
|
||||
#include "GUI/TextArea.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
|
||||
GEM_EXPORT DisplayMessage * displaymsg;
|
||||
|
||||
@@ -33,11 +34,11 @@ static int strref_table[STRREF_COUNT];
|
||||
|
||||
#define PALSIZE 8
|
||||
static Color ActorColor[PALSIZE];
|
||||
static const char* DisplayFormatName = "[color=%lX]%s - [/color][p][color=%lX]%s[/color][/p]";
|
||||
static const char* DisplayFormatAction = "[color=%lX]%s - [/color][p][color=%lX]%s %s[/color][/p]";
|
||||
static const char* DisplayFormat = "[/color][p][color=%lX]%s[/color][/p]";
|
||||
static const char* DisplayFormatValue = "[/color][p][color=%lX]%s: %d[/color][/p]";
|
||||
static const char* DisplayFormatNameString = "[color=%lX]%s - [/color][p][color=%lX]%s: %s[/color][/p]";
|
||||
static const char* DisplayFormatName = "[color=%06X]%s - [/color][p][color=%06X]%s[/color][/p]";
|
||||
static const char* DisplayFormatAction = "[color=%06X]%s - [/color][p][color=%06X]%s %s[/color][/p]";
|
||||
static const char* DisplayFormat = "[/color][p][color=%06X]%s[/color][/p]";
|
||||
static const char* DisplayFormatValue = "[/color][p][color=%06X]%s: %d[/color][/p]";
|
||||
static const char* DisplayFormatNameString = "[color=%06X]%s - [/color][p][color=%06X]%s: %s[/color][/p]";
|
||||
|
||||
DisplayMessage::DisplayMessage(void) {
|
||||
ReadStrrefs();
|
||||
@@ -61,7 +62,7 @@ void DisplayMessage::DisplayString(const char* Text, Scriptable *target) const
|
||||
{
|
||||
Label *l = core->GetMessageLabel();
|
||||
if (l) {
|
||||
l->SetText(Text, 0);
|
||||
l->SetText(Text);
|
||||
}
|
||||
TextArea *ta = core->GetMessageTextArea();
|
||||
if (ta) {
|
||||
@@ -161,7 +162,7 @@ void DisplayMessage::DisplayConstantStringNameString(int stridx, unsigned int co
|
||||
actor_color = GetSpeakerColor(name, actor);
|
||||
char* text = core->GetString( strref_table[stridx], IE_STR_SOUND );
|
||||
char* text2 = core->GetString( strref_table[stridx2], IE_STR_SOUND );
|
||||
int newlen = (int)(strlen( DisplayFormat ) + strlen(name) + strlen( text ) + strlen(text2) + 18);
|
||||
int newlen = (int)(strlen( DisplayFormat ) + strlen(name) + strlen( text ) + strlen(text2) + 20);
|
||||
char* newstr = ( char* ) malloc( newlen );
|
||||
if (strlen(text2)) {
|
||||
snprintf( newstr, newlen, DisplayFormatNameString, actor_color, name, color, text, text2 );
|
||||
|
||||
@@ -28,8 +28,11 @@
|
||||
#define DISPLAYMESSAGE_H
|
||||
|
||||
#include "exports.h"
|
||||
#include "ie_types.h"
|
||||
|
||||
#include "ActorMgr.h"
|
||||
#include <cstdlib>
|
||||
|
||||
class Scriptable;
|
||||
|
||||
class GEM_EXPORT DisplayMessage
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "SymbolMgr.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
#include "Spell.h" //needs for the source flags bitfield
|
||||
#include "TableMgr.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
@@ -97,7 +98,7 @@ bool EffectQueue::match_ids(Actor *target, int table, ieDword value)
|
||||
|
||||
static const bool fx_instant[MAX_TIMING_MODE]={true,true,true,false,false,false,false,false,true,true,true};
|
||||
|
||||
inline bool IsInstant(ieByte timingmode)
|
||||
static inline bool IsInstant(ieByte timingmode)
|
||||
{
|
||||
if( timingmode>=MAX_TIMING_MODE) return false;
|
||||
return fx_instant[timingmode];
|
||||
@@ -105,7 +106,7 @@ inline bool IsInstant(ieByte timingmode)
|
||||
|
||||
static const bool fx_equipped[MAX_TIMING_MODE]={false,false,true,false,false,true,false,false,true,false,false};
|
||||
|
||||
inline bool IsEquipped(ieByte timingmode)
|
||||
static inline bool IsEquipped(ieByte timingmode)
|
||||
{
|
||||
if( timingmode>=MAX_TIMING_MODE) return false;
|
||||
return fx_equipped[timingmode];
|
||||
@@ -114,7 +115,7 @@ inline bool IsEquipped(ieByte timingmode)
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
static const bool fx_relative[MAX_TIMING_MODE]={true,false,false,true,true,true,false,false,false,false,false};
|
||||
|
||||
inline bool NeedPrepare(ieWord timingmode)
|
||||
static inline bool NeedPrepare(ieWord timingmode)
|
||||
{
|
||||
if( timingmode>=MAX_TIMING_MODE) return false;
|
||||
return fx_relative[timingmode];
|
||||
@@ -128,7 +129,7 @@ inline bool NeedPrepare(ieWord timingmode)
|
||||
static const int fx_prepared[MAX_TIMING_MODE]={DURATION,PERMANENT,PERMANENT,DELAYED, //0-3
|
||||
DELAYED,DELAYED,DELAYED,DELAYED,PERMANENT,PERMANENT,PERMANENT}; //4-7
|
||||
|
||||
inline int DelayType(ieByte timingmode)
|
||||
static inline int DelayType(ieByte timingmode)
|
||||
{
|
||||
if( timingmode>=MAX_TIMING_MODE) return INVALID;
|
||||
return fx_prepared[timingmode];
|
||||
@@ -137,7 +138,7 @@ inline int DelayType(ieByte timingmode)
|
||||
//which effects are removable
|
||||
static const bool fx_removable[MAX_TIMING_MODE]={true,true,false,true,true,false,true,true,false,false,true};
|
||||
|
||||
inline int IsRemovable(ieByte timingmode)
|
||||
static inline int IsRemovable(ieByte timingmode)
|
||||
{
|
||||
if( timingmode>=MAX_TIMING_MODE) return INVALID;
|
||||
return fx_removable[timingmode];
|
||||
@@ -157,18 +158,18 @@ FX_DURATION_AFTER_EXPIRES,FX_DURATION_PERMANENT_UNSAVED, //4,5
|
||||
FX_DURATION_JUST_EXPIRED,FX_DURATION_JUST_EXPIRED,FX_DURATION_JUST_EXPIRED,//6,8
|
||||
FX_DURATION_JUST_EXPIRED,FX_DURATION_JUST_EXPIRED};//9,10
|
||||
|
||||
inline ieByte TriggeredEffect(ieByte timingmode)
|
||||
static inline ieByte TriggeredEffect(ieByte timingmode)
|
||||
{
|
||||
if( timingmode>=MAX_TIMING_MODE) return false;
|
||||
return fx_triggered[timingmode];
|
||||
}
|
||||
|
||||
int compare_effects(const void *a, const void *b)
|
||||
static int compare_effects(const void *a, const void *b)
|
||||
{
|
||||
return stricmp(((EffectRef *) a)->Name,((EffectRef *) b)->Name);
|
||||
}
|
||||
|
||||
int find_effect(const void *a, const void *b)
|
||||
static int find_effect(const void *a, const void *b)
|
||||
{
|
||||
return stricmp((const char *) a,((const EffectRef *) b)->Name);
|
||||
}
|
||||
@@ -180,15 +181,14 @@ static EffectDesc* FindEffect(const char* effectname)
|
||||
}
|
||||
void *tmp = bsearch(effectname, effectnames, effectnames_count, sizeof(EffectDesc), find_effect);
|
||||
if( !tmp) {
|
||||
printMessage( "EffectQueue", "", YELLOW);
|
||||
printf("Couldn't assign effect: %s\n", effectname );
|
||||
printMessage("EffectQueue", "Couldn't assign effect: %s\n", YELLOW, effectname);
|
||||
}
|
||||
return (EffectDesc *) tmp;
|
||||
}
|
||||
|
||||
static EffectRef fx_protection_from_display_string_ref = { "Protection:String", -1 };
|
||||
|
||||
inline static void ResolveEffectRef(EffectRef &effect_reference)
|
||||
static inline void ResolveEffectRef(EffectRef &effect_reference)
|
||||
{
|
||||
if( effect_reference.opcode==-1) {
|
||||
EffectDesc* ref = FindEffect(effect_reference.Name);
|
||||
@@ -250,12 +250,11 @@ bool Init_EffectQueue()
|
||||
//reverse linking opcode number
|
||||
//using this unused field
|
||||
if( (poi->opcode!=-1) && effectname[0]!='*') {
|
||||
printf("Clashing Opcodes FN: %d vs. %d, %s\n", i, poi->opcode, effectname);
|
||||
abort();
|
||||
error("EffectQueue", "Clashing Opcodes FN: %d vs. %d, %s\n", i, poi->opcode, effectname);
|
||||
}
|
||||
poi->opcode = i;
|
||||
}
|
||||
//printf("-------- FN: %d, %s\n", i, effectname);
|
||||
//print("-------- FN: %d, %s\n", i, effectname);
|
||||
}
|
||||
core->DelSymbol( eT );
|
||||
|
||||
@@ -485,6 +484,7 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
int flg;
|
||||
ieDword spec = 0;
|
||||
Actor *st = (self && (self->Type==ST_ACTOR)) ?(Actor *) self:NULL;
|
||||
Effect* new_fx;
|
||||
|
||||
switch (fx->Target) {
|
||||
case FX_TARGET_ORIGINAL:
|
||||
@@ -509,6 +509,7 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
break;
|
||||
|
||||
case FX_TARGET_ALL_BUT_SELF:
|
||||
new_fx = new Effect;
|
||||
map=self->GetCurrentArea();
|
||||
i= map->GetActorCount(true);
|
||||
while(i--) {
|
||||
@@ -517,13 +518,15 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
if( st==actor) {
|
||||
continue;
|
||||
}
|
||||
fx->SetPosition(actor->Pos);
|
||||
memcpy( new_fx, fx, sizeof( Effect ) );
|
||||
new_fx->SetPosition(actor->Pos);
|
||||
|
||||
flg = ApplyEffect( actor, fx, 1 );
|
||||
if( fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( fx, flg==FX_INSERT );
|
||||
flg = ApplyEffect( actor, new_fx, 1 );
|
||||
if( new_fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( new_fx, flg==FX_INSERT );
|
||||
}
|
||||
}
|
||||
delete new_fx;
|
||||
flg = FX_APPLIED;
|
||||
break;
|
||||
|
||||
@@ -534,6 +537,7 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
map = self->GetCurrentArea();
|
||||
spec = st->GetStat(IE_SPECIFIC);
|
||||
|
||||
new_fx = new Effect;
|
||||
//GetActorCount(false) returns all nonparty critters
|
||||
i = map->GetActorCount(false);
|
||||
while(i--) {
|
||||
@@ -541,13 +545,15 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
if( actor->GetStat(IE_SPECIFIC)!=spec) {
|
||||
continue;
|
||||
}
|
||||
fx->SetPosition(actor->Pos);
|
||||
memcpy( new_fx, fx, sizeof( Effect ) );
|
||||
new_fx->SetPosition(actor->Pos);
|
||||
|
||||
flg = ApplyEffect( actor, fx, 1 );
|
||||
if( fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( fx, flg==FX_INSERT );
|
||||
flg = ApplyEffect( actor, new_fx, 1 );
|
||||
if( new_fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( new_fx, flg==FX_INSERT );
|
||||
}
|
||||
}
|
||||
delete new_fx;
|
||||
flg = FX_APPLIED;
|
||||
break;
|
||||
case FX_TARGET_OTHER_SIDE:
|
||||
@@ -557,6 +563,7 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
map = self->GetCurrentArea();
|
||||
spec = pretarget->GetStat(IE_SPECIFIC);
|
||||
|
||||
new_fx = new Effect;
|
||||
//GetActorCount(false) returns all nonparty critters
|
||||
i = map->GetActorCount(false);
|
||||
while(i--) {
|
||||
@@ -564,14 +571,16 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
if( actor->GetStat(IE_SPECIFIC)!=spec) {
|
||||
continue;
|
||||
}
|
||||
fx->SetPosition(actor->Pos);
|
||||
memcpy( new_fx, fx, sizeof( Effect ) );
|
||||
new_fx->SetPosition(actor->Pos);
|
||||
|
||||
flg = ApplyEffect( actor, fx, 1 );
|
||||
flg = ApplyEffect( actor, new_fx, 1 );
|
||||
//GetActorCount can now return all nonparty critters
|
||||
if( fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( fx, flg==FX_INSERT );
|
||||
if( new_fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( new_fx, flg==FX_INSERT );
|
||||
}
|
||||
}
|
||||
delete new_fx;
|
||||
flg = FX_APPLIED;
|
||||
break;
|
||||
case FX_TARGET_PRESET:
|
||||
@@ -587,54 +596,63 @@ int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const
|
||||
|
||||
case FX_TARGET_PARTY:
|
||||
all_party:
|
||||
new_fx = new Effect;
|
||||
game = core->GetGame();
|
||||
i = game->GetPartySize(false);
|
||||
while(i--) {
|
||||
Actor* actor = game->GetPC( i, false );
|
||||
fx->SetPosition(actor->Pos);
|
||||
memcpy( new_fx, fx, sizeof( Effect ) );
|
||||
new_fx->SetPosition(actor->Pos);
|
||||
|
||||
flg = ApplyEffect( actor, fx, 1 );
|
||||
if( fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( fx, flg==FX_INSERT );
|
||||
flg = ApplyEffect( actor, new_fx, 1 );
|
||||
if( new_fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( new_fx, flg==FX_INSERT );
|
||||
}
|
||||
}
|
||||
delete new_fx;
|
||||
flg = FX_APPLIED;
|
||||
break;
|
||||
|
||||
case FX_TARGET_ALL:
|
||||
new_fx = new Effect;
|
||||
map = self->GetCurrentArea();
|
||||
i = map->GetActorCount(true);
|
||||
while(i--) {
|
||||
Actor* actor = map->GetActor( i, true );
|
||||
fx->SetPosition(actor->Pos);
|
||||
memcpy( new_fx, fx, sizeof( Effect ) );
|
||||
new_fx->SetPosition(actor->Pos);
|
||||
|
||||
flg = ApplyEffect( actor, fx, 1 );
|
||||
if( fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( fx, flg==FX_INSERT );
|
||||
flg = ApplyEffect( actor, new_fx, 1 );
|
||||
if( new_fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( new_fx, flg==FX_INSERT );
|
||||
}
|
||||
}
|
||||
delete new_fx;
|
||||
flg = FX_APPLIED;
|
||||
break;
|
||||
|
||||
case FX_TARGET_ALL_BUT_PARTY:
|
||||
new_fx = new Effect;
|
||||
map = self->GetCurrentArea();
|
||||
i = map->GetActorCount(false);
|
||||
while(i--) {
|
||||
Actor* actor = map->GetActor( i, false );
|
||||
fx->SetPosition(actor->Pos);
|
||||
memcpy( new_fx, fx, sizeof( Effect ) );
|
||||
new_fx->SetPosition(actor->Pos);
|
||||
|
||||
flg = ApplyEffect( actor, fx, 1 );
|
||||
flg = ApplyEffect( actor, new_fx, 1 );
|
||||
//GetActorCount can now return all nonparty critters
|
||||
if( fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( fx, flg==FX_INSERT );
|
||||
if( new_fx->TimingMode != FX_DURATION_JUST_EXPIRED) {
|
||||
actor->fxqueue.AddEffect( new_fx, flg==FX_INSERT );
|
||||
}
|
||||
}
|
||||
delete new_fx;
|
||||
flg = FX_APPLIED;
|
||||
break;
|
||||
|
||||
case FX_TARGET_UNKNOWN:
|
||||
default:
|
||||
printf( "Unknown FX target type: %d\n", fx->Target);
|
||||
print( "Unknown FX target type: %d\n", fx->Target);
|
||||
flg = FX_ABORT;
|
||||
break;
|
||||
}
|
||||
@@ -681,7 +699,7 @@ int EffectQueue::AddAllEffects(Actor* target, const Point &destination) const
|
||||
}
|
||||
|
||||
//resisted effect based on level
|
||||
inline bool check_level(Actor *target, Effect *fx)
|
||||
static inline bool check_level(Actor *target, Effect *fx)
|
||||
{
|
||||
//skip non level based effects
|
||||
//check if an effect has no level based resistance, but instead the dice sizes/count
|
||||
@@ -729,7 +747,7 @@ inline bool check_level(Actor *target, Effect *fx)
|
||||
|
||||
//roll for the effect probability, there is a high and a low treshold, the d100
|
||||
//roll should hit in the middle
|
||||
inline bool check_probability(Effect* fx)
|
||||
static inline bool check_probability(Effect* fx)
|
||||
{
|
||||
//watch for this, probability1 is the high number
|
||||
//probability2 is the low number
|
||||
@@ -773,7 +791,7 @@ static EffectRef fx_secondary_type_bounce_dec_ref = { "Bounce:SecondaryTypeDec",
|
||||
static EffectRef fx_spelltrap = { "SpellTrap", -1 };
|
||||
|
||||
//this is for whole spell immunity/bounce
|
||||
inline static void DecreaseEffect(Effect *efx)
|
||||
static inline void DecreaseEffect(Effect *efx)
|
||||
{
|
||||
efx->Parameter1--;
|
||||
if( (int) efx->Parameter1<1) {
|
||||
@@ -950,11 +968,11 @@ static bool check_resistance(Actor* actor, Effect* fx)
|
||||
|
||||
//opcode immunity
|
||||
if( actor->fxqueue.HasEffectWithParam(fx_opcode_immunity_ref, fx->Opcode) ) {
|
||||
printf ("immune to effect: %s\n", (char*) Opcodes[fx->Opcode].Name);
|
||||
print ("immune to effect: %s\n", (char*) Opcodes[fx->Opcode].Name);
|
||||
return true;
|
||||
}
|
||||
if( actor->fxqueue.HasEffectWithParam(fx_opcode_immunity2_ref, fx->Opcode) ) {
|
||||
printf ("immune2 to effect: %s\n", (char*) Opcodes[fx->Opcode].Name);
|
||||
print ("immune2 to effect: %s\n", (char*) Opcodes[fx->Opcode].Name);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -984,10 +1002,10 @@ static bool check_resistance(Actor* actor, Effect* fx)
|
||||
|
||||
//magic immunity
|
||||
ieDword val = actor->GetStat(IE_RESISTMAGIC);
|
||||
if( fx->random_value < val) {
|
||||
if( (signed) fx->random_value < (signed) val) {
|
||||
// when using biased magic resistance non-hostile spells aren't resisted
|
||||
if ((selective_mr && (fx->SourceFlags&SF_HOSTILE)) || !selective_mr) {
|
||||
printf ("effect resisted: %s\n", (char*) Opcodes[fx->Opcode].Name);
|
||||
print ("effect resisted: %s\n", (char*) Opcodes[fx->Opcode].Name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1006,7 +1024,7 @@ static bool check_resistance(Actor* actor, Effect* fx)
|
||||
if( fx->IsSaveForHalfDamage) {
|
||||
fx->Parameter1/=2;
|
||||
} else {
|
||||
printf ("%s saved against effect: %s\n", actor->GetName(1), (char*) Opcodes[fx->Opcode].Name);
|
||||
print ("%s saved against effect: %s\n", actor->GetName(1), (char*) Opcodes[fx->Opcode].Name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1025,7 +1043,7 @@ static bool check_resistance(Actor* actor, Effect* fx)
|
||||
|
||||
int EffectQueue::ApplyEffect(Actor* target, Effect* fx, ieDword first_apply, ieDword resistance) const
|
||||
{
|
||||
//printf( "FX 0x%02x: %s(%d, %d)\n", fx->Opcode, effectnames[fx->Opcode].Name, fx->Parameter1, fx->Parameter2 );
|
||||
//print( "FX 0x%02x: %s(%d, %d)\n", fx->Opcode, effectnames[fx->Opcode].Name, fx->Parameter1, fx->Parameter2 );
|
||||
if( fx->Opcode >= MAX_EFFECTS) {
|
||||
fx->TimingMode = FX_DURATION_JUST_EXPIRED;
|
||||
return FX_NOT_APPLIED;
|
||||
@@ -1110,15 +1128,14 @@ int EffectQueue::ApplyEffect(Actor* target, Effect* fx, ieDword first_apply, ieD
|
||||
break;
|
||||
//this shouldn't happen
|
||||
default:
|
||||
printf("Unknown delay type: %d (from %d)\n", DelayType(fx->TimingMode&0xff), fx->TimingMode);
|
||||
abort();
|
||||
error("EffectQueue", "Unknown delay type: %d (from %d)\n", DelayType(fx->TimingMode&0xff), fx->TimingMode);
|
||||
}
|
||||
|
||||
EffectFunction fn = 0;
|
||||
if( fx->Opcode<MAX_EFFECTS) {
|
||||
fn = Opcodes[fx->Opcode].Function;
|
||||
if (!(target || (Opcodes[fx->Opcode].Flags & EFFECT_NO_ACTOR))) {
|
||||
printf("targetless opcode without EFFECT_NO_ACTOR: %d, skipping\n", fx->Opcode);
|
||||
print("targetless opcode without EFFECT_NO_ACTOR: %d, skipping\n", fx->Opcode);
|
||||
return FX_NOT_APPLIED;
|
||||
}
|
||||
}
|
||||
@@ -1152,7 +1169,7 @@ int EffectQueue::ApplyEffect(Actor* target, Effect* fx, ieDword first_apply, ieD
|
||||
case FX_PERMANENT:
|
||||
//don't stick around if it was executed permanently
|
||||
//for example, a permanent strength modifier effect
|
||||
if( (fx->TimingMode == FX_DURATION_INSTANT_PERMANENT) ) {
|
||||
if( fx->TimingMode == FX_DURATION_INSTANT_PERMANENT ) {
|
||||
fx->TimingMode = FX_DURATION_JUST_EXPIRED;
|
||||
}
|
||||
break;
|
||||
@@ -1179,7 +1196,7 @@ int EffectQueue::ApplyEffect(Actor* target, Effect* fx, ieDword first_apply, ieD
|
||||
#define MATCH_PROJECTILE() if((*f)->Projectile!=projectile) { continue; }
|
||||
|
||||
static const bool fx_live[MAX_TIMING_MODE]={true,true,true,false,false,false,false,false,true,true,false};
|
||||
inline bool IsLive(ieByte timingmode)
|
||||
static inline bool IsLive(ieByte timingmode)
|
||||
{
|
||||
if( timingmode>=MAX_TIMING_MODE) return false;
|
||||
return fx_live[timingmode];
|
||||
@@ -1727,7 +1744,7 @@ bool EffectQueue::HasAnyDispellableEffect() const
|
||||
|
||||
void EffectQueue::dump() const
|
||||
{
|
||||
printf( "EFFECT QUEUE:\n" );
|
||||
print( "EFFECT QUEUE:\n" );
|
||||
int i = 0;
|
||||
std::list< Effect* >::const_iterator f;
|
||||
for ( f = effects.begin(); f != effects.end(); f++ ) {
|
||||
@@ -1737,7 +1754,7 @@ void EffectQueue::dump() const
|
||||
if( fx->Opcode < MAX_EFFECTS)
|
||||
Name = (char*) Opcodes[fx->Opcode].Name;
|
||||
|
||||
printf( " %2d: 0x%02x: %s (%d, %d) S:%s\n", i++, fx->Opcode, Name, fx->Parameter1, fx->Parameter2, fx->Source );
|
||||
print( " %2d: 0x%02x: %s (%d, %d) S:%s\n", i++, fx->Opcode, Name, fx->Parameter1, fx->Parameter2, fx->Source );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1766,12 +1783,13 @@ bool EffectQueue::HasDuration(Effect *fx)
|
||||
static EffectRef fx_variable_ref = { "Variable:StoreLocalVariable", -1 };
|
||||
|
||||
//returns true if the effect must be saved
|
||||
//variables are saved differently
|
||||
bool EffectQueue::Persistent(Effect* fx)
|
||||
{
|
||||
//we save this as variable
|
||||
// local variable effects self-destruct if they were processed already
|
||||
// but if they weren't processed, e.g. in a global actor, we must save them
|
||||
// TODO: do we really need to special-case this? leaving it for now - fuzzie
|
||||
if( fx->Opcode==(ieDword) ResolveEffect(fx_variable_ref)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (fx->TimingMode) {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "Effect.h"
|
||||
#include "Region.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
|
||||
class Actor;
|
||||
|
||||
87
project/jni/application/gemrb/gemrb/core/FileCache.cpp
Normal file
87
project/jni/application/gemrb/gemrb/core/FileCache.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "FileCache.h"
|
||||
|
||||
#include "Compressor.h"
|
||||
#include "Interface.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "System/FileStream.h"
|
||||
#include "System/VFS.h"
|
||||
|
||||
DataStream* CacheCompressedStream(DataStream *stream, const char* filename, int length, bool overwrite)
|
||||
{
|
||||
if (!core->IsAvailable(PLUGIN_COMPRESSION_ZLIB)) {
|
||||
print( "No Compression Manager Available.\nCannot Load Compressed File.\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char fname[_MAX_PATH];
|
||||
ExtractFileFromPath(fname, filename);
|
||||
char path[_MAX_PATH];
|
||||
PathJoin(path, core->CachePath, fname, NULL);
|
||||
|
||||
if (overwrite || !file_exists(path)) {
|
||||
FileStream out;
|
||||
if (!out.Create(path)) {
|
||||
printMessage("FileCache", "Cannot write %s.\n", RED, path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PluginHolder<Compressor> comp(PLUGIN_COMPRESSION_ZLIB);
|
||||
if (comp->Decompress(&out, stream, length) != GEM_OK)
|
||||
return NULL;
|
||||
} else {
|
||||
stream->Seek(length, GEM_CURRENT_POS);
|
||||
}
|
||||
return FileStream::OpenFile(path);
|
||||
}
|
||||
|
||||
DataStream* CacheFile(const char* path)
|
||||
{
|
||||
if (!core->GameOnCD)
|
||||
return FileStream::OpenFile(path);
|
||||
|
||||
char filename[_MAX_PATH];
|
||||
char cachedfile[_MAX_PATH];
|
||||
ExtractFileFromPath(filename, path);
|
||||
PathJoin(cachedfile, core->CachePath, filename, NULL);
|
||||
|
||||
if (!file_exists(cachedfile)) { // File was not found in cache
|
||||
FileStream* src = FileStream::OpenFile(path);
|
||||
FileStream* dest = FileStream::OpenFile(cachedfile);
|
||||
if (!src || !dest) {
|
||||
error("Cache", "CachedFile failed to write to cached file '%s' (from '%s')\n", cachedfile, path);
|
||||
}
|
||||
|
||||
size_t blockSize = 1024 * 1000;
|
||||
char buff[1024 * 1000];
|
||||
do {
|
||||
if (blockSize > src->Remains())
|
||||
blockSize = src->Remains();
|
||||
size_t len = src->Read(buff, blockSize);
|
||||
size_t c = dest->Write(buff, len);
|
||||
if (c != len) {
|
||||
error("Cache", "CacheFile failed to write to cached file '%s' (from '%s')\n", cachedfile, path);
|
||||
}
|
||||
} while (src->Remains());
|
||||
delete src;
|
||||
delete dest;
|
||||
}
|
||||
return FileStream::OpenFile(cachedfile);
|
||||
}
|
||||
27
project/jni/application/gemrb/gemrb/core/FileCache.h
Normal file
27
project/jni/application/gemrb/gemrb/core/FileCache.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef FILECACHE_H
|
||||
#define FILECACHE_H
|
||||
|
||||
#include "System/DataStream.h"
|
||||
|
||||
GEM_EXPORT DataStream* CacheCompressedStream(DataStream *stream, const char* filename, int length = 0, bool overwrite = false);
|
||||
GEM_EXPORT DataStream* CacheFile(const char* path);
|
||||
|
||||
#endif
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "GameData.h"
|
||||
#include "Interface.h"
|
||||
#include "Palette.h"
|
||||
#include "Sprite2D.h"
|
||||
#include "Video.h"
|
||||
|
||||
#include <cassert>
|
||||
@@ -146,7 +147,7 @@ void Font::PrintFromLine(int startrow, Region rgn, const unsigned char* string,
|
||||
size_t len = strlen( ( char* ) string );
|
||||
char* tmp = ( char* ) malloc( len + 1 );
|
||||
memcpy( tmp, ( char * ) string, len + 1 );
|
||||
SetupString( tmp, rgn.w, NoColor );
|
||||
SetupString( tmp, rgn.w, NoColor, initials, enablecap );
|
||||
int ystep = 0;
|
||||
if (Alignment & IE_FONT_SINGLE_LINE) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
@@ -320,7 +321,7 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string,
|
||||
len--;
|
||||
}
|
||||
|
||||
SetupString( tmp, rgn.w, NoColor );
|
||||
SetupString( tmp, rgn.w, NoColor, initials, capital );
|
||||
int ystep = 0;
|
||||
if (Alignment & IE_FONT_SINGLE_LINE) {
|
||||
|
||||
@@ -454,39 +455,36 @@ int Font::CalcStringWidth(const char* string, bool NoColor) const
|
||||
size_t ret = 0, len = strlen( string );
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (( ( unsigned char ) string[i] ) == '[' && !NoColor) {
|
||||
i++;
|
||||
if (i>=len)
|
||||
break;
|
||||
char tag[256];
|
||||
int k = 0;
|
||||
for (k = 0; k < 256; k++) {
|
||||
if (string[i] == ']') {
|
||||
tag[k] = 0;
|
||||
break;
|
||||
}
|
||||
tag[k] = string[i++];
|
||||
while(i<len && ((unsigned char) string[i]) != ']') {
|
||||
i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ret += size[( unsigned char ) string[i] - 1].w;
|
||||
}
|
||||
return ( int ) ret;
|
||||
}
|
||||
|
||||
void Font::SetupString(char* string, unsigned int width, bool NoColor) const
|
||||
void Font::SetupString(char* string, unsigned int width, bool NoColor, Font *initials, bool enablecap) const
|
||||
{
|
||||
size_t len = strlen( string );
|
||||
unsigned int psx = PARAGRAPH_START_X;
|
||||
int lastpos = 0;
|
||||
unsigned int x = psx, wx = 0;
|
||||
bool endword = false;
|
||||
int initials_rows = 0;
|
||||
int initials_x = 0;
|
||||
for (size_t pos = 0; pos < len; pos++) {
|
||||
if (x + wx > width) {
|
||||
// we wrapped, force a new line somewhere
|
||||
if (!endword && ( x == psx ))
|
||||
lastpos = ( int ) pos;
|
||||
else
|
||||
string[lastpos] = 0;
|
||||
x = psx;
|
||||
if (initials_rows > 0) {
|
||||
initials_rows--;
|
||||
x += initials_x;
|
||||
}
|
||||
}
|
||||
if (string[pos] == 0) {
|
||||
continue;
|
||||
@@ -495,9 +493,14 @@ void Font::SetupString(char* string, unsigned int width, bool NoColor) const
|
||||
if (string[pos] == '\r')
|
||||
string[pos] = ' ';
|
||||
if (string[pos] == '\n') {
|
||||
// force a new line here
|
||||
string[pos] = 0;
|
||||
x = psx;
|
||||
wx = 0;
|
||||
if (initials_rows > 0) {
|
||||
initials_rows--;
|
||||
x += initials_x;
|
||||
}
|
||||
lastpos = ( int ) pos;
|
||||
endword = true;
|
||||
continue;
|
||||
@@ -515,6 +518,14 @@ void Font::SetupString(char* string, unsigned int width, bool NoColor) const
|
||||
}
|
||||
tag[k] = string[pos++];
|
||||
}
|
||||
if (strnicmp( tag, "capital=",8)==0) {
|
||||
int capital = 0;
|
||||
sscanf( tag, "capital=%d", &capital);
|
||||
if (capital) {
|
||||
enablecap=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (stricmp( "p", tag ) == 0) {
|
||||
psx = x;
|
||||
continue;
|
||||
@@ -531,6 +542,14 @@ void Font::SetupString(char* string, unsigned int width, bool NoColor) const
|
||||
}
|
||||
|
||||
wx += size[( unsigned char ) string[pos] - 1].w;
|
||||
if (initials && enablecap) {
|
||||
wx += initials->size[(unsigned char) string[pos] - 1].w;
|
||||
enablecap=false;
|
||||
initials_x = wx;
|
||||
//how many more lines to be indented (one was already indented)
|
||||
initials_rows = (initials->maxHeight-1)/maxHeight;
|
||||
continue;
|
||||
}
|
||||
if (( string[pos] == ' ' ) || ( string[pos] == '-' )) {
|
||||
x += wx;
|
||||
wx = 0;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <vector>
|
||||
|
||||
class Palette;
|
||||
class Sprite2D;
|
||||
|
||||
struct StringList {
|
||||
Sprite2D*** strings;
|
||||
@@ -99,7 +100,7 @@ public:
|
||||
void SetPalette(Palette* pal);
|
||||
/** Returns width of the string rendered in this font in pixels */
|
||||
int CalcStringWidth(const char* string, bool NoColor = false) const;
|
||||
void SetupString(char* string, unsigned int width, bool NoColor = false) const;
|
||||
void SetupString(char* string, unsigned int width, bool NoColor = false, Font *initials = NULL, bool enablecap = false) const;
|
||||
/** Sets ASCII code of the first character in the font.
|
||||
* (it allows remapping numeric fonts from \000 to '0') */
|
||||
void SetFirstChar(unsigned char first);
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "GUI/Button.h"
|
||||
|
||||
#include "GUI/GameControl.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/ScrollBar.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
#include "defsounds.h"
|
||||
#include "win32def.h"
|
||||
@@ -125,7 +128,7 @@ void Button::CloseUpColor()
|
||||
unsigned long newtime;
|
||||
|
||||
Changed = true;
|
||||
GetTime( newtime );
|
||||
newtime = GetTickCount();
|
||||
if (newtime<starttime) {
|
||||
return;
|
||||
}
|
||||
@@ -572,7 +575,7 @@ void Button::OnMouseLeave(unsigned short /*x*/, unsigned short /*y*/)
|
||||
|
||||
|
||||
/** Sets the Text of the current control */
|
||||
int Button::SetText(const char* string, int /*pos*/)
|
||||
void Button::SetText(const char* string)
|
||||
{
|
||||
free(Text);
|
||||
Text = NULL;
|
||||
@@ -589,7 +592,6 @@ int Button::SetText(const char* string, int /*pos*/)
|
||||
hasText = true;
|
||||
}
|
||||
Changed = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set Event Handler */
|
||||
@@ -713,7 +715,7 @@ void Button::SetHorizontalOverlay(double clip, const Color &src, const Color &de
|
||||
Flags |= IE_GUI_BUTTON_HORIZONTAL;
|
||||
SourceRGB=src;
|
||||
DestRGB=dest;
|
||||
GetTime( starttime );
|
||||
starttime = GetTickCount();
|
||||
starttime += 40;
|
||||
}
|
||||
Clipping = clip;
|
||||
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
/** Sets the Button State */
|
||||
void SetState(unsigned char state);
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char* string, int pos = 0);
|
||||
void SetText(const char* string);
|
||||
/** Sets the Picture */
|
||||
void SetPicture(Sprite2D* Picture);
|
||||
/** Clears the list of Pictures */
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "Palette.h"
|
||||
#include "ScriptEngine.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
|
||||
Console::Console(void)
|
||||
{
|
||||
@@ -93,10 +94,9 @@ void Console::SetBackGround(Sprite2D* back)
|
||||
Back = back;
|
||||
}
|
||||
/** Sets the Text of the current control */
|
||||
int Console::SetText(const char* string, int /*pos*/)
|
||||
void Console::SetText(const char* string)
|
||||
{
|
||||
strncpy( ( char * ) Buffer, string, max );
|
||||
return 0;
|
||||
}
|
||||
/** Key Press Event */
|
||||
void Console::OnKeyPress(unsigned char Key, unsigned short /*Mod*/)
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
/** Set BackGround */
|
||||
void SetBackGround(Sprite2D* back);
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char* string, int pos = 0);
|
||||
void SetText(const char* string);
|
||||
private:
|
||||
/** Text Editing Cursor Sprite */
|
||||
Sprite2D* Cursor;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "GUI/Control.h"
|
||||
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
#include "win32def.h"
|
||||
@@ -29,6 +30,10 @@
|
||||
#include "ScriptEngine.h"
|
||||
#include "Video.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "Variables.h"
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
@@ -92,6 +97,10 @@ void Control::ResetEventHandler(EventHandler handler)
|
||||
handler = NULL;
|
||||
}
|
||||
|
||||
void Control::SetText(const char* /*string*/)
|
||||
{
|
||||
}
|
||||
|
||||
int Control::RunEventHandler(EventHandler handler)
|
||||
{
|
||||
if (InHandler) {
|
||||
@@ -121,67 +130,33 @@ int Control::RunEventHandler(EventHandler handler)
|
||||
}
|
||||
|
||||
/** Key Press Event */
|
||||
void Control::OnKeyPress(unsigned char Key, unsigned short /*Mod*/)
|
||||
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) {
|
||||
case 'o': // volume down
|
||||
case 'p': // volume up
|
||||
int Ambients, Movie, Music, SFX, Voices;
|
||||
core->GetDictionary()->Lookup( "Volume Ambients", (ieDword&)Ambients );
|
||||
core->GetDictionary()->Lookup( "Volume Movie", (ieDword&)Movie );
|
||||
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(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 {
|
||||
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", Ambients );
|
||||
core->GetDictionary()->SetAt( "Volume Movie", Movie );
|
||||
core->GetDictionary()->SetAt( "Volume Music", Music );
|
||||
core->GetDictionary()->SetAt( "Volume SFX", SFX );
|
||||
core->GetDictionary()->SetAt( "Volume Voices", Voices );
|
||||
core->GetAudioDrv()->UpdateVolume();
|
||||
break;
|
||||
}
|
||||
#else
|
||||
(void)Key; // unused, fool the compiler
|
||||
#endif
|
||||
//print("OnKeyPress: CtrlID = 0x%08X, Key = %c (0x%02hX)\n", (unsigned int) ControlID, Key, Key);
|
||||
}
|
||||
|
||||
/** Key Release Event */
|
||||
void Control::OnKeyRelease(unsigned char /*Key*/, unsigned short /*Mod*/)
|
||||
{
|
||||
//printf( "OnKeyRelease: CtrlID = 0x%08X, Key = %c (0x%02hX)\n", (unsigned int) ControlID, Key, Key );
|
||||
//print( "OnKeyRelease: CtrlID = 0x%08X, Key = %c (0x%02hX)\n", (unsigned int) ControlID, Key, Key );
|
||||
}
|
||||
|
||||
/** Mouse Enter Event */
|
||||
void Control::OnMouseEnter(unsigned short /*x*/, unsigned short /*y*/)
|
||||
{
|
||||
// printf("OnMouseEnter: CtrlID = 0x%08X, x = %hd, y = %hd\n", (unsigned int) ControlID, x, y);
|
||||
// print("OnMouseEnter: CtrlID = 0x%08X, x = %hd, y = %hd\n", (unsigned int) ControlID, x, y);
|
||||
}
|
||||
|
||||
/** Mouse Leave Event */
|
||||
void Control::OnMouseLeave(unsigned short /*x*/, unsigned short /*y*/)
|
||||
{
|
||||
// printf("OnMouseLeave: CtrlID = 0x%08X, x = %hd, y = %hd\n", (unsigned int) ControlID, x, y);
|
||||
// print("OnMouseLeave: CtrlID = 0x%08X, x = %hd, y = %hd\n", (unsigned int) ControlID, x, y);
|
||||
}
|
||||
|
||||
/** Mouse Over Event */
|
||||
void Control::OnMouseOver(unsigned short /*x*/, unsigned short /*y*/)
|
||||
{
|
||||
//printf("OnMouseOver: CtrlID = 0x%08X, x = %hd, y = %hd\n", (unsigned int) ControlID, x, y);
|
||||
//print("OnMouseOver: CtrlID = 0x%08X, x = %hd, y = %hd\n", (unsigned int) ControlID, x, y);
|
||||
}
|
||||
|
||||
/** Mouse Button Down */
|
||||
@@ -200,7 +175,7 @@ void Control::OnMouseDown(unsigned short x, unsigned short y,
|
||||
void Control::OnMouseUp(unsigned short /*x*/, unsigned short /*y*/,
|
||||
unsigned short /*Button*/, unsigned short /*Mod*/)
|
||||
{
|
||||
//printf("OnMouseUp: CtrlID = 0x%08X, x = %hd, y = %hd, Button = %d, Mos = %hd\n", (unsigned int) ControlID, x, y, Button, Mod);
|
||||
//print("OnMouseUp: CtrlID = 0x%08X, x = %hd, y = %hd, Button = %d, Mos = %hd\n", (unsigned int) ControlID, x, y, Button, Mod);
|
||||
}
|
||||
|
||||
/** Special Key Press */
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
/** Draws the Control on the Output Display */
|
||||
virtual void Draw(unsigned short x, unsigned short y) = 0;
|
||||
/** Sets the Text of the current control */
|
||||
virtual int SetText(const char* string, int pos = 0) = 0;
|
||||
virtual void SetText(const char* string);
|
||||
/** Sets the Tooltip text of the current control */
|
||||
int SetTooltip(const char* string);
|
||||
/** Displays the tooltip text, Worldmap handles this differently */
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
EventMgr::EventMgr(void)
|
||||
{
|
||||
@@ -236,7 +237,7 @@ void EventMgr::MouseDown(unsigned short x, unsigned short y, unsigned short Butt
|
||||
Control *ctrl;
|
||||
unsigned long thisTime;
|
||||
|
||||
GetTime( thisTime );
|
||||
thisTime = GetTickCount();
|
||||
if (ClickMatch(x, y, thisTime)) {
|
||||
Button |= GEM_MB_DOUBLECLICK;
|
||||
dc_x = 0;
|
||||
|
||||
@@ -28,14 +28,13 @@
|
||||
#ifndef EVENTMGR_H
|
||||
#define EVENTMGR_H
|
||||
|
||||
#include "GUI/Control.h"
|
||||
|
||||
#include "exports.h"
|
||||
|
||||
#include "WindowMgr.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Control;
|
||||
class Window;
|
||||
|
||||
#define GEM_LEFT 0x81
|
||||
#define GEM_RIGHT 0x82
|
||||
#define GEM_UP 0x83
|
||||
|
||||
@@ -25,17 +25,25 @@
|
||||
#include "DialogHandler.h"
|
||||
#include "DisplayMessage.h"
|
||||
#include "Effect.h"
|
||||
#include "Font.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "ImageMgr.h"
|
||||
#include "Interface.h"
|
||||
#include "Item.h"
|
||||
#include "KeyMap.h"
|
||||
#include "PathFinder.h"
|
||||
#include "SaveGameIterator.h"
|
||||
#include "ScriptEngine.h"
|
||||
#include "TableMgr.h"
|
||||
#include "TextArea.h"
|
||||
#include "TileMap.h"
|
||||
#include "Video.h"
|
||||
#include "damages.h"
|
||||
#include "GameScript/GSUtils.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/Window.h"
|
||||
#include "Scriptable/Container.h"
|
||||
#include "Scriptable/Door.h"
|
||||
#include "Scriptable/InfoPoint.h"
|
||||
@@ -47,11 +55,7 @@
|
||||
#define DEBUG_SHOW_DOORS DEBUG_SHOW_CONTAINERS
|
||||
#define DEBUG_SHOW_LIGHTMAP 0x08
|
||||
|
||||
#ifdef TOUCHSCREEN
|
||||
# define SCROLL_BORDER 32
|
||||
#else
|
||||
# define SCROLL_BORDER 5
|
||||
#endif
|
||||
#define SCROLL_BORDER 5
|
||||
|
||||
static const Color cyan = {
|
||||
0x00, 0xff, 0xff, 0xff
|
||||
@@ -132,9 +136,7 @@ GameControl::GameControl(void)
|
||||
lastCursor = IE_CURSOR_NORMAL;
|
||||
moveX = moveY = 0;
|
||||
scrolling = false;
|
||||
#ifdef TOUCHSCREEN
|
||||
touched=false;
|
||||
#endif
|
||||
touchScrollAreasEnabled = false;
|
||||
numScrollCursor = 0;
|
||||
DebugFlags = 0;
|
||||
AIUpdateCounter = 1;
|
||||
@@ -149,6 +151,12 @@ GameControl::GameControl(void)
|
||||
} else {
|
||||
ScreenFlags = SF_CENTERONACTOR;
|
||||
}
|
||||
core->GetDictionary()->Lookup("TouchScrollAreas",tmp);
|
||||
if (tmp) {
|
||||
touchScrollAreasEnabled = true;
|
||||
touched = false;
|
||||
scrollAreasWidth = 32;
|
||||
}
|
||||
LeftCount = 0;
|
||||
BottomCount = 0;
|
||||
RightCount = 0;
|
||||
@@ -271,7 +279,8 @@ void GameControl::CreateMovement(Actor *actor, const Point &p)
|
||||
|
||||
actor->AddAction( action );
|
||||
// force action so that we get target recticles immediately
|
||||
actor->ProcessActions(true);
|
||||
// FIXME
|
||||
actor->ProcessActions();
|
||||
}
|
||||
|
||||
GameControl::~GameControl(void)
|
||||
@@ -587,30 +596,24 @@ 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 */
|
||||
int GameControl::SetText(const char* /*string*/, int /*pos*/)
|
||||
{
|
||||
return 0;
|
||||
if (touchScrollAreasEnabled) {
|
||||
if (moveY < 0 && scrolling)
|
||||
video->DrawLine(screen.x+4, screen.y+scrollAreasWidth, screen.w+screen.x-4, screen.y+scrollAreasWidth, red);
|
||||
else
|
||||
video->DrawLine(screen.x+4, screen.y+scrollAreasWidth, screen.w+screen.x-4, screen.y+scrollAreasWidth, gray);
|
||||
if (moveY > 0 && scrolling)
|
||||
video->DrawLine(screen.x+4, screen.h-scrollAreasWidth, screen.w+screen.x-4, screen.h-scrollAreasWidth, red);
|
||||
else
|
||||
video->DrawLine(screen.x+4, screen.h-scrollAreasWidth, screen.w+screen.x-4, screen.h-scrollAreasWidth, gray);
|
||||
if (moveX < 0 && scrolling)
|
||||
video->DrawLine(screen.x+scrollAreasWidth, screen.y+4, screen.x+scrollAreasWidth, screen.h+screen.y-4, red);
|
||||
else
|
||||
video->DrawLine(screen.x+scrollAreasWidth, screen.y+4, screen.x+scrollAreasWidth, screen.h+screen.y-4, gray);
|
||||
if (moveX > 0 && scrolling)
|
||||
video->DrawLine(screen.w+screen.x-scrollAreasWidth, screen.y+4, screen.w+screen.x-scrollAreasWidth, screen.h-4, red);
|
||||
else
|
||||
video->DrawLine(screen.w+screen.x-scrollAreasWidth, screen.y+4, screen.w+screen.x-scrollAreasWidth, screen.h-4, gray);
|
||||
}
|
||||
}
|
||||
|
||||
/** Key Press Event */
|
||||
@@ -663,10 +666,6 @@ void GameControl::OnKeyPress(unsigned char Key, unsigned short /*Mod*/)
|
||||
SelectActor(pc+1, true);
|
||||
break;
|
||||
#ifdef ANDROID
|
||||
case 'o':
|
||||
case 'p':
|
||||
Control::OnKeyPress(Key, 0);
|
||||
break;
|
||||
case 'c': // show containers in ANDROID, GEM_ALT is not possible to use
|
||||
DebugFlags |= DEBUG_SHOW_CONTAINERS;
|
||||
return;
|
||||
@@ -881,7 +880,7 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod)
|
||||
area->MoveVisibleGroundPiles(p);
|
||||
break;
|
||||
case 'x': // shows coordinates on the map
|
||||
printf( "%s [%d.%d]\n", area->GetScriptName(), p.x, p.y );
|
||||
print( "%s [%d.%d]\n", area->GetScriptName(), p.x, p.y );
|
||||
break;
|
||||
case 'g'://shows loaded areas and other game information
|
||||
game->DebugDump();
|
||||
@@ -997,22 +996,22 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod)
|
||||
break;
|
||||
case '4': //show all traps and infopoints
|
||||
DebugFlags ^= DEBUG_SHOW_INFOPOINTS;
|
||||
printf("Show traps and infopoints %s\n", DebugFlags & DEBUG_SHOW_INFOPOINTS ? "ON" : "OFF");
|
||||
print("Show traps and infopoints %s\n", DebugFlags & DEBUG_SHOW_INFOPOINTS ? "ON" : "OFF");
|
||||
break;
|
||||
case '6': //show the lightmap
|
||||
DebugFlags ^= DEBUG_SHOW_LIGHTMAP;
|
||||
printf("Show lightmap %s\n", DebugFlags & DEBUG_SHOW_LIGHTMAP ? "ON" : "OFF");
|
||||
print("Show lightmap %s\n", DebugFlags & DEBUG_SHOW_LIGHTMAP ? "ON" : "OFF");
|
||||
break;
|
||||
case '7': //toggles fog of war
|
||||
core->FogOfWar ^= FOG_DRAWFOG;
|
||||
printf("Show Fog-Of-War: %s\n", core->FogOfWar & FOG_DRAWFOG ? "ON" : "OFF");
|
||||
print("Show Fog-Of-War: %s\n", core->FogOfWar & FOG_DRAWFOG ? "ON" : "OFF");
|
||||
break;
|
||||
case '8': //show searchmap over area
|
||||
core->FogOfWar ^= FOG_DRAWSEARCHMAP;
|
||||
printf("Show searchmap %s\n", core->FogOfWar & FOG_DRAWSEARCHMAP ? "ON" : "OFF");
|
||||
print("Show searchmap %s\n", core->FogOfWar & FOG_DRAWSEARCHMAP ? "ON" : "OFF");
|
||||
break;
|
||||
default:
|
||||
printf( "KeyRelease:%d - %d\n", Key, Mod );
|
||||
print( "KeyRelease:%d - %d\n", Key, Mod );
|
||||
break;
|
||||
}
|
||||
return; //return from cheatkeys
|
||||
@@ -1030,6 +1029,7 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod)
|
||||
displaymsg->DisplayConstantString(STR_UNPAUSED,0xff0000);
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case 'm':
|
||||
core->GetGUIScriptEngine()->RunFunction("GUIMA","OpenMapWindow");
|
||||
break;
|
||||
@@ -1042,6 +1042,13 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod)
|
||||
case 'r':
|
||||
core->GetGUIScriptEngine()->RunFunction("GUIREC","OpenRecordsWindow");
|
||||
break;
|
||||
case 'p':
|
||||
core->GetGUIScriptEngine()->RunFunction("GUIPR","OpenPriestWindow");
|
||||
break;
|
||||
case 'w':
|
||||
core->GetGUIScriptEngine()->RunFunction("GUIMG","OpenMageWindow");
|
||||
break;
|
||||
*/
|
||||
case 'q': //quicksave
|
||||
QuickSave();
|
||||
break;
|
||||
@@ -1052,6 +1059,7 @@ void GameControl::OnKeyRelease(unsigned char Key, unsigned short Mod)
|
||||
DebugFlags &= ~DEBUG_SHOW_CONTAINERS;
|
||||
break;
|
||||
default:
|
||||
core->GetKeyMap()->ResolveKey(Key,0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1062,8 +1070,7 @@ void GameControl::DisplayTooltip() {
|
||||
Map* area = game->GetCurrentArea( );
|
||||
if (area) {
|
||||
Actor *actor = area->GetActorByGlobalID(lastActorID);
|
||||
if (actor && (actor->GetStat(IE_STATE_ID)&STATE_DEAD || actor->GetInternalFlag()&IF_JUSTDIED)) {
|
||||
// checking IF_JUSTDIED is kind of horrid, but seems necessary
|
||||
if (actor && (actor->GetStat(IE_STATE_ID)&STATE_DEAD || actor->GetInternalFlag()&IF_REALLYDIED)) {
|
||||
// no tooltips for dead actors!
|
||||
actor->SetOver( false );
|
||||
lastActorID = 0;
|
||||
@@ -1230,61 +1237,61 @@ void GameControl::OnMouseOver(unsigned short x, unsigned short y)
|
||||
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 {
|
||||
if (touchScrollAreasEnabled) {
|
||||
int mousescrollspd = core->GetMouseScrollSpeed();
|
||||
Region region;
|
||||
Map* map;
|
||||
Point mapsize;
|
||||
Region viewport = core->GetVideoDriver()->GetViewport();
|
||||
moveX = 0;
|
||||
moveY = 0;
|
||||
scrolling = false;
|
||||
Video* video = core->GetVideoDriver();
|
||||
video->SetDragCursor(NULL);
|
||||
// Top scroll area
|
||||
region=Region(XPos, YPos, Width, YPos+scrollAreasWidth);
|
||||
if (region.PointInside(x, y)) {
|
||||
// Check for end of map area
|
||||
if (viewport.y > 0)
|
||||
moveY = -mousescrollspd;
|
||||
}
|
||||
// Bottom scroll area
|
||||
region=Region(XPos, Height-scrollAreasWidth, 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+scrollAreasWidth, Height);
|
||||
if (region.PointInside(x, y)) {
|
||||
// Check for end of map area
|
||||
if(viewport.x > 0)
|
||||
moveX = -mousescrollspd;
|
||||
}
|
||||
// Right scroll area
|
||||
region=Region(Width-scrollAreasWidth, 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;
|
||||
@@ -1461,38 +1468,35 @@ void GameControl::OnGlobalMouseMove(unsigned short x, unsigned short y)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TOUCHSCREEN
|
||||
int mousescrollspd = core->GetMouseScrollSpeed();
|
||||
if (!touchScrollAreasEnabled) {
|
||||
int mousescrollspd = core->GetMouseScrollSpeed();
|
||||
|
||||
if (x <= SCROLL_BORDER)
|
||||
moveX = -mousescrollspd;
|
||||
else {
|
||||
if (x >= ( core->Width - SCROLL_BORDER ))
|
||||
moveX = mousescrollspd;
|
||||
else
|
||||
moveX = 0;
|
||||
}
|
||||
if (y <= SCROLL_BORDER)
|
||||
moveY = -mousescrollspd;
|
||||
else {
|
||||
if (y >= ( core->Height - SCROLL_BORDER ))
|
||||
moveY = mousescrollspd;
|
||||
else
|
||||
moveY = 0;
|
||||
}
|
||||
if (x <= SCROLL_BORDER)
|
||||
moveX = -mousescrollspd;
|
||||
else {
|
||||
if (x >= ( core->Width - SCROLL_BORDER ))
|
||||
moveX = mousescrollspd;
|
||||
else
|
||||
moveX = 0;
|
||||
}
|
||||
if (y <= SCROLL_BORDER)
|
||||
moveY = -mousescrollspd;
|
||||
else {
|
||||
if (y >= ( core->Height - SCROLL_BORDER ))
|
||||
moveY = mousescrollspd;
|
||||
else
|
||||
moveY = 0;
|
||||
}
|
||||
|
||||
if (moveX != 0 || moveY != 0) {
|
||||
scrolling = true;
|
||||
} else if (scrolling) {
|
||||
scrolling = false;
|
||||
if (moveX != 0 || moveY != 0) {
|
||||
scrolling = true;
|
||||
} else if (scrolling) {
|
||||
scrolling = false;
|
||||
|
||||
Video* video = core->GetVideoDriver();
|
||||
video->SetDragCursor(NULL);
|
||||
Video* video = core->GetVideoDriver();
|
||||
video->SetDragCursor(NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)x;
|
||||
(void)y;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GameControl::UpdateScrolling() {
|
||||
@@ -1738,7 +1742,7 @@ void GameControl::HandleContainer(Container *container, Actor *actor)
|
||||
return;
|
||||
}
|
||||
|
||||
if ((target_mode == TARGET_MODE_PICK)) {
|
||||
if (target_mode == TARGET_MODE_PICK) {
|
||||
TryToPick(actor, container);
|
||||
return;
|
||||
}
|
||||
@@ -1798,14 +1802,16 @@ bool GameControl::HandleActiveRegion(InfoPoint *trap, Actor * actor, Point &p)
|
||||
//don't bother with this region further
|
||||
return true;
|
||||
}
|
||||
if ((target_mode == TARGET_MODE_PICK)) {
|
||||
if (target_mode == TARGET_MODE_PICK) {
|
||||
TryToDisarm(actor, trap);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch(trap->Type) {
|
||||
case ST_TRAVEL:
|
||||
actor->UseExit(trap->GetGlobalID());
|
||||
trap->AddTrigger(TriggerEntry(trigger_clicked, actor->GetGlobalID()));
|
||||
// exit usage is handled by caller for now
|
||||
// actor->UseExit(trap->GetGlobalID());
|
||||
return false;
|
||||
case ST_TRIGGER:
|
||||
//the importer shouldn't load the script
|
||||
@@ -1816,16 +1822,12 @@ bool GameControl::HandleActiveRegion(InfoPoint *trap, Actor * actor, Point &p)
|
||||
//reset trap and deactivated flags
|
||||
if (trap->Scripts[0]) {
|
||||
if (!(trap->Flags&TRAP_DEACTIVATED) ) {
|
||||
trap->LastTriggerObject = trap->LastTrigger = actor->GetGlobalID();
|
||||
trap->ImmediateEvent();
|
||||
trap->AddTrigger(TriggerEntry(trigger_clicked, actor->GetGlobalID()));
|
||||
//directly feeding the event, even if there are actions in the queue
|
||||
trap->Scripts[0]->Update();
|
||||
trap->ProcessActions(true);
|
||||
//if reset trap flag not set, deactivate it
|
||||
//hmm, better not, info triggers don't deactivate themselves on click
|
||||
//if (!(trap->Flags&TRAP_RESET)) {
|
||||
// trap->Flags|=TRAP_DEACTIVATED;
|
||||
//}
|
||||
//trap->Scripts[0]->Update();
|
||||
// FIXME
|
||||
trap->ExecuteScript(1);
|
||||
trap->ProcessActions();
|
||||
}
|
||||
} else {
|
||||
if (trap->overHeadText) {
|
||||
@@ -1875,9 +1877,7 @@ void GameControl::OnMouseDown(unsigned short x, unsigned short y, unsigned short
|
||||
StartY = py;
|
||||
SelectionRect.w = 0;
|
||||
SelectionRect.h = 0;
|
||||
#ifdef TOUCHSCREEN
|
||||
touched=true;
|
||||
#endif
|
||||
if (touchScrollAreasEnabled) touched=true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1902,33 +1902,33 @@ 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 );
|
||||
if (touchScrollAreasEnabled) {
|
||||
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;
|
||||
}
|
||||
free( ab );
|
||||
DrawSelectionRect = false;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (DrawSelectionRect) {
|
||||
Actor** ab;
|
||||
unsigned int count = area->GetActorInRect( ab, SelectionRect,true );
|
||||
@@ -1999,11 +1999,10 @@ void GameControl::OnMouseUp(unsigned short x, unsigned short y, unsigned short B
|
||||
while(i--) {
|
||||
game->selected[i]->UseExit(exitID);
|
||||
}
|
||||
} else {
|
||||
if (HandleActiveRegion(overInfoPoint, pc, p)) {
|
||||
core->SetEventFlag(EF_RESETTARGET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (HandleActiveRegion(overInfoPoint, pc, p)) {
|
||||
core->SetEventFlag(EF_RESETTARGET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2387,8 +2386,8 @@ void GameControl::HandleWindowHide(const char *WindowName, const char *WindowPos
|
||||
}
|
||||
return;
|
||||
}
|
||||
printMessage("GameControl", "Invalid Window Index: ", LIGHT_RED);
|
||||
printf("%s:%u\n",WindowName, index);
|
||||
printMessage("GameControl", "Invalid Window Index: %s:%u\n", LIGHT_RED,
|
||||
WindowName, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2440,8 +2439,8 @@ void GameControl::HandleWindowReveal(const char *WindowName, const char *WindowP
|
||||
}
|
||||
return;
|
||||
}
|
||||
printMessage("GameControl", "Invalid Window Index ", LIGHT_RED);
|
||||
printf("%s:%u\n",WindowName, index);
|
||||
printMessage("GameControl", "Invalid Window Index %s:%u\n", LIGHT_RED,
|
||||
WindowName, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2695,7 +2694,7 @@ Sprite2D* GameControl::GetScreenshot(bool show_gui)
|
||||
//copies a downscaled screenshot into a sprite for save game preview
|
||||
Sprite2D* GameControl::GetPreview()
|
||||
{
|
||||
// We get preview by first taking a screenshot of size 640x405,
|
||||
// We get preview by first taking a screenshot of quintuple size of the preview control size (a few pixels bigger only in pst),
|
||||
// centered in the display. This is to get a decent picture for
|
||||
// higher screen resolutions.
|
||||
// FIXME: how do orig games solve that?
|
||||
@@ -2708,27 +2707,20 @@ Sprite2D* GameControl::GetPreview()
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
} else {
|
||||
w = 640;
|
||||
w = 515;
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
} else {
|
||||
h = 405;
|
||||
h = 385;
|
||||
}
|
||||
|
||||
if (!x)
|
||||
y = 0;
|
||||
|
||||
int hf = HideGUI ();
|
||||
signed char v = Owner->Visible;
|
||||
Owner->Visible = WINDOW_VISIBLE;
|
||||
Draw (0, 0);
|
||||
Owner->Visible = v;
|
||||
Sprite2D *screenshot = video->GetScreenshot( Region(x, y, w, h) );
|
||||
if (hf) {
|
||||
UnhideGUI ();
|
||||
}
|
||||
core->DrawWindows();
|
||||
|
||||
Sprite2D* preview = video->SpriteScaleDown ( screenshot, 5 );
|
||||
|
||||
@@ -96,8 +96,6 @@ public:
|
||||
public:
|
||||
/** Draws the Control on the Output Display */
|
||||
void Draw(unsigned short x, unsigned short y);
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char* string, int pos = 0);
|
||||
/** Sets multiple quicksaves flag*/
|
||||
static void MultipleQuickSaves(int arg);
|
||||
void SetTracker(Actor *actor, ieDword dist);
|
||||
@@ -112,9 +110,12 @@ private:
|
||||
Region SelectionRect;
|
||||
short StartX, StartY;
|
||||
//int action;
|
||||
#ifdef TOUCHSCREEN
|
||||
|
||||
// following variables used for touch scroll areas
|
||||
bool touchScrollAreasEnabled; // true, if scroll areas enabled
|
||||
bool touched; // true, if player touched screen (left button down and hold)
|
||||
#endif
|
||||
unsigned int scrollAreasWidth; // scroll areas width
|
||||
|
||||
public:
|
||||
Door* overDoor;
|
||||
Container* overContainer;
|
||||
|
||||
@@ -25,8 +25,10 @@
|
||||
#include "GameData.h"
|
||||
#include "Interface.h"
|
||||
#include "Palette.h"
|
||||
#include "Sprite2D.h"
|
||||
#include "Variables.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
Label::Label(Font* font)
|
||||
{
|
||||
@@ -71,7 +73,7 @@ void Label::Draw(unsigned short x, unsigned short y)
|
||||
|
||||
}
|
||||
/** This function sets the actual Label Text */
|
||||
int Label::SetText(const char* string, int /*pos*/)
|
||||
void Label::SetText(const char* string)
|
||||
{
|
||||
if (Buffer )
|
||||
free( Buffer );
|
||||
@@ -95,7 +97,6 @@ int Label::SetText(const char* string, int /*pos*/)
|
||||
if (Owner) {
|
||||
Owner->Invalidate();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/** Sets the Foreground Font Color */
|
||||
void Label::SetColor(Color col, Color bac)
|
||||
@@ -119,7 +120,7 @@ void Label::SetAlignment(unsigned char Alignment)
|
||||
void Label::OnMouseUp(unsigned short x, unsigned short y,
|
||||
unsigned short /*Button*/, unsigned short /*Mod*/)
|
||||
{
|
||||
//printf( "Label::OnMouseUp\n" );
|
||||
//print( "Label::OnMouseUp\n" );
|
||||
if (( x <= Width ) && ( y <= Height )) {
|
||||
if (VarName[0] != 0) {
|
||||
core->GetDictionary()->SetAt( VarName, Value );
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
/** Draws the Control on the Output Display */
|
||||
void Draw(unsigned short x, unsigned short y);
|
||||
/** This function sets the actual Label Text */
|
||||
int SetText(const char* string, int pos = 0);
|
||||
void SetText(const char* string);
|
||||
/** Sets the Foreground Font Color */
|
||||
void SetColor(Color col, Color bac);
|
||||
/** Sets the Alignment of Text */
|
||||
|
||||
@@ -22,9 +22,14 @@
|
||||
#include "win32def.h"
|
||||
|
||||
#include "Game.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "Interface.h"
|
||||
#include "Map.h"
|
||||
#include "Sprite2D.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/Window.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
|
||||
#define MAP_NO_NOTES 0
|
||||
#define MAP_VIEW_NOTES 1
|
||||
@@ -224,6 +229,11 @@ void MapControl::Draw(unsigned short XWin, unsigned short YWin)
|
||||
vp.w = ViewWidth;
|
||||
vp.h = ViewHeight;
|
||||
|
||||
if ((vp.x + vp.w) >= MAP_TO_SCREENX( Width ))
|
||||
vp.w = MAP_TO_SCREENX( Width ) - vp.x;
|
||||
if ((vp.y + vp.h) >= MAP_TO_SCREENY( Height ))
|
||||
vp.h = MAP_TO_SCREENY( Height ) - vp.y;
|
||||
|
||||
video->DrawRect( vp, colors[green], false, false );
|
||||
|
||||
// Draw PCs' ellipses
|
||||
@@ -269,18 +279,8 @@ void MapControl::Draw(unsigned short XWin, unsigned short YWin)
|
||||
}
|
||||
|
||||
/** Key Press Event */
|
||||
void MapControl::OnKeyPress(unsigned char Key, unsigned short /*Mod*/)
|
||||
void MapControl::OnKeyPress(unsigned char /*Key*/, unsigned short /*Mod*/)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
switch(Key) {
|
||||
case 'o':
|
||||
case 'p':
|
||||
Control::OnKeyPress(Key, 0);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
(void)Key; // unused, fool the compiler
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Key Release Event */
|
||||
@@ -289,7 +289,7 @@ void MapControl::OnKeyRelease(unsigned char Key, unsigned short Mod)
|
||||
switch (Key) {
|
||||
case '\t':
|
||||
//not GEM_TAB
|
||||
printf( "TAB released\n" );
|
||||
print( "TAB released\n" );
|
||||
return;
|
||||
case 'f':
|
||||
if (Mod & GEM_MOD_CTRL)
|
||||
@@ -471,7 +471,7 @@ void MapControl::OnMouseUp(unsigned short x, unsigned short y, unsigned short Bu
|
||||
return;
|
||||
case MAP_VIEW_NOTES:
|
||||
//left click allows setting only when in MAP_SET_NOTE mode
|
||||
if ((Button == GEM_MB_ACTION) ) {
|
||||
if (Button == GEM_MB_ACTION) {
|
||||
ViewHandle(x,y);
|
||||
}
|
||||
ClickHandle(Button);
|
||||
@@ -499,10 +499,10 @@ void MapControl::OnSpecialKeyPress(unsigned char Key)
|
||||
ScrollY += 64;
|
||||
break;
|
||||
case GEM_ALT:
|
||||
printf( "ALT pressed\n" );
|
||||
print( "ALT pressed\n" );
|
||||
break;
|
||||
case GEM_TAB:
|
||||
printf( "TAB pressed\n" );
|
||||
print( "TAB pressed\n" );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -79,8 +79,6 @@ public:
|
||||
void DrawFog(unsigned short XWin, unsigned short YWin);
|
||||
/** Compute parameters after changes in control's or screen geometry */
|
||||
void Realize();
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char* /*string*/, int /*pos*/) { return 0; }
|
||||
|
||||
/** Key Press Event */
|
||||
void OnKeyPress(unsigned char Key, unsigned short Mod);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -162,12 +163,6 @@ void Progressbar::SetSliderPos(int x, int y, int x2, int y2)
|
||||
CapYPos=y2;
|
||||
}
|
||||
|
||||
/* dummy virtual function */
|
||||
int Progressbar::SetText(const char* /*string*/, int /*pos*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Progressbar::SetEvent(int eventType, EventHandler handler)
|
||||
{
|
||||
Changed = true;
|
||||
|
||||
@@ -60,8 +60,6 @@ public:
|
||||
void SetBarCap(Sprite2D *img3);
|
||||
/** Sets the mos coordinates for the progressbar filler mos/cap */
|
||||
void SetSliderPos(int x, int y, int x2, int y2);
|
||||
/** Dummy function */
|
||||
int SetText(const char * string, int pos = 0);
|
||||
/** Redraws a progressbar which is associated with VariableName */
|
||||
void RedrawProgressbar(const char *VariableName, int Sum);
|
||||
/** Set handler for specified event */
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "Interface.h"
|
||||
#include "Variables.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
ScrollBar::ScrollBar(void)
|
||||
{
|
||||
@@ -263,12 +265,6 @@ void ScrollBar::OnMouseOver(unsigned short /*x*/, unsigned short y)
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets the Text of the current control */
|
||||
int ScrollBar::SetText(const char* /*string*/, int /*pos*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Sets the Maximum Value of the ScrollBar */
|
||||
void ScrollBar::SetMax(unsigned short Max)
|
||||
{
|
||||
|
||||
@@ -77,8 +77,6 @@ private: //Private attributes
|
||||
unsigned short Pos;
|
||||
/** Scroll Bar Status */
|
||||
unsigned short State;
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char* string, int pos = 0);
|
||||
public:
|
||||
void SetImage(unsigned char type, Sprite2D* img);
|
||||
/** Sets the Maximum Value of the ScrollBar */
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "Interface.h"
|
||||
#include "Variables.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -273,12 +274,6 @@ void Slider::OnMouseOver(unsigned short x, unsigned short /*y*/)
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets the Text of the current control */
|
||||
int Slider::SetText(const char* /*string*/, int /*pos*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Sets the slider change event */
|
||||
bool Slider::SetEvent(int eventType, EventHandler handler)
|
||||
{
|
||||
|
||||
@@ -60,8 +60,6 @@ public:
|
||||
void SetPosition(unsigned int pos);
|
||||
/** Sets the selected image */
|
||||
void SetImage(unsigned char type, Sprite2D * img);
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char * string, int pos = 0);
|
||||
/** Sets the State of the Slider */
|
||||
void SetState(int arg) { State=(unsigned char) arg; }
|
||||
/** Redraws a slider which is associated with VariableName */
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "Palette.h"
|
||||
#include "Variables.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/Window.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -126,7 +128,7 @@ void TextArea::Draw(unsigned short x, unsigned short y)
|
||||
{
|
||||
unsigned long thisTime;
|
||||
|
||||
GetTime( thisTime);
|
||||
thisTime = GetTickCount();
|
||||
if (thisTime>starttime) {
|
||||
starttime = thisTime+ticks;
|
||||
smooth--;
|
||||
@@ -297,36 +299,26 @@ int TextArea::SetScrollBar(Control* ptr)
|
||||
}
|
||||
|
||||
/** Sets the Actual Text */
|
||||
int TextArea::SetText(const char* text, int pos)
|
||||
void TextArea::SetText(const char* text)
|
||||
{
|
||||
if (pos==0) {
|
||||
if (!text[0]) {
|
||||
lines.clear();
|
||||
lrows.clear();
|
||||
}
|
||||
if (!text[0]) {
|
||||
Clear();
|
||||
}
|
||||
|
||||
if (lines.size() == 0) {
|
||||
pos = -1;
|
||||
}
|
||||
}
|
||||
if (pos >= ( int ) lines.size()) {
|
||||
return -1;
|
||||
}
|
||||
int newlen = ( int ) strlen( text );
|
||||
|
||||
if (pos == -1) {
|
||||
if (lines.size() == 0) {
|
||||
char* str = (char *) malloc( newlen + 1 );
|
||||
memcpy( str, text, newlen + 1 );
|
||||
lines.push_back( str );
|
||||
lrows.push_back( 0 );
|
||||
} else {
|
||||
lines[pos] = (char *) realloc( lines[pos], newlen + 1 );
|
||||
memcpy( lines[pos], text, newlen + 1 );
|
||||
lines[0] = (char *) realloc( lines[0], newlen + 1 );
|
||||
memcpy( lines[0], text, newlen + 1 );
|
||||
}
|
||||
CurPos = newlen;
|
||||
CurLine = lines.size()-1;
|
||||
UpdateControls();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TextArea::SetMinRow(bool enable)
|
||||
@@ -479,7 +471,7 @@ void TextArea::OnKeyPress(unsigned char Key, unsigned short /*Mod*/)
|
||||
Owner->Invalidate();
|
||||
Changed = true;
|
||||
int len = GetRowLength(CurLine);
|
||||
//printf("len: %d Before: %s\n",len, lines[CurLine]);
|
||||
//print("len: %d Before: %s\n",len, lines[CurLine]);
|
||||
lines[CurLine] = (char *) realloc( lines[CurLine], len + 2 );
|
||||
for (int i = len; i > CurPos; i--) {
|
||||
lines[CurLine][i] = lines[CurLine][i - 1];
|
||||
@@ -487,7 +479,7 @@ void TextArea::OnKeyPress(unsigned char Key, unsigned short /*Mod*/)
|
||||
lines[CurLine][CurPos] = Key;
|
||||
lines[CurLine][len + 1] = 0;
|
||||
CurPos++;
|
||||
//printf("pos: %d After: %s\n",CurPos, lines[CurLine]);
|
||||
//print("pos: %d After: %s\n",CurPos, lines[CurLine]);
|
||||
CalcRowCount();
|
||||
RunEventHandler( TextAreaOnChange );
|
||||
}
|
||||
@@ -577,7 +569,7 @@ void TextArea::OnSpecialKeyPress(unsigned char Key)
|
||||
break;
|
||||
case GEM_DELETE:
|
||||
len = GetRowLength(CurLine);
|
||||
//printf("len: %d Before: %s\n",len, lines[CurLine]);
|
||||
//print("len: %d Before: %s\n",len, lines[CurLine]);
|
||||
if (CurPos>=len) {
|
||||
//TODO: merge next line
|
||||
break;
|
||||
@@ -586,12 +578,12 @@ void TextArea::OnSpecialKeyPress(unsigned char Key)
|
||||
for (i = CurPos; i < len; i++) {
|
||||
lines[CurLine][i] = lines[CurLine][i + 1];
|
||||
}
|
||||
//printf("pos: %d After: %s\n",CurPos, lines[CurLine]);
|
||||
//print("pos: %d After: %s\n",CurPos, lines[CurLine]);
|
||||
break;
|
||||
case GEM_BACKSP:
|
||||
len = GetRowLength(CurLine);
|
||||
if (CurPos != 0) {
|
||||
//printf("len: %d Before: %s\n",len, lines[CurLine]);
|
||||
//print("len: %d Before: %s\n",len, lines[CurLine]);
|
||||
if (len<1) {
|
||||
break;
|
||||
}
|
||||
@@ -601,15 +593,15 @@ void TextArea::OnSpecialKeyPress(unsigned char Key)
|
||||
}
|
||||
lines[CurLine][len - 1] = 0;
|
||||
CurPos--;
|
||||
//printf("pos: %d After: %s\n",CurPos, lines[CurLine]);
|
||||
//print("pos: %d After: %s\n",CurPos, lines[CurLine]);
|
||||
} else {
|
||||
if (CurLine) {
|
||||
//TODO: merge lines
|
||||
int oldline = CurLine;
|
||||
CurLine--;
|
||||
int old = GetRowLength(CurLine);
|
||||
//printf("len: %d Before: %s\n",old, lines[CurLine]);
|
||||
//printf("len: %d Before: %s\n",len, lines[oldline]);
|
||||
//print("len: %d Before: %s\n",old, lines[CurLine]);
|
||||
//print("len: %d Before: %s\n",len, lines[oldline]);
|
||||
lines[CurLine] = (char *) realloc (lines[CurLine], len+old);
|
||||
memcpy(lines[CurLine]+old, lines[oldline],len);
|
||||
free(lines[oldline]);
|
||||
@@ -617,13 +609,13 @@ void TextArea::OnSpecialKeyPress(unsigned char Key)
|
||||
lines.erase(lines.begin()+oldline);
|
||||
lrows.erase(lrows.begin()+oldline);
|
||||
CurPos = old;
|
||||
//printf("pos: %d len: %d After: %s\n",CurPos, GetRowLength(CurLine), lines[CurLine]);
|
||||
//print("pos: %d len: %d After: %s\n",CurPos, GetRowLength(CurLine), lines[CurLine]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GEM_RETURN:
|
||||
//add an empty line after CurLine
|
||||
//printf("pos: %d Before: %s\n",CurPos, lines[CurLine]);
|
||||
//print("pos: %d Before: %s\n",CurPos, lines[CurLine]);
|
||||
lrows.insert(lrows.begin()+CurLine, 0);
|
||||
len = GetRowLength(CurLine);
|
||||
//copy the text after the cursor into the new line
|
||||
@@ -637,8 +629,8 @@ void TextArea::OnSpecialKeyPress(unsigned char Key)
|
||||
//move cursor to next line beginning
|
||||
CurLine++;
|
||||
CurPos=0;
|
||||
//printf("len: %d After: %s\n",GetRowLength(CurLine-1), lines[CurLine-1]);
|
||||
//printf("len: %d After: %s\n",GetRowLength(CurLine), lines[CurLine]);
|
||||
//print("len: %d After: %s\n",GetRowLength(CurLine-1), lines[CurLine-1]);
|
||||
//print("len: %d After: %s\n",GetRowLength(CurLine), lines[CurLine]);
|
||||
break;
|
||||
}
|
||||
CalcRowCount();
|
||||
@@ -780,7 +772,7 @@ void TextArea::OnMouseOver(unsigned short /*x*/, unsigned short y)
|
||||
if (seltext != (int) i)
|
||||
core->RedrawAll();
|
||||
seltext = ( int ) i;
|
||||
//printf("CtrlId = 0x%08lx, seltext = %d, rows = %d, row = %d, r = %d\n", ControlID, i, rows, row, r);
|
||||
//print("CtrlId = 0x%08lx, seltext = %d, rows = %d, row = %d, r = %d\n", ControlID, i, rows, row, r);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -788,7 +780,7 @@ void TextArea::OnMouseOver(unsigned short /*x*/, unsigned short y)
|
||||
core->RedrawAll();
|
||||
}
|
||||
seltext = -1;
|
||||
//printf("CtrlId = 0x%08lx, seltext = %d, rows %d, row %d, r = %d\n", ControlID, seltext, rows, row, r);
|
||||
//print("CtrlId = 0x%08lx, seltext = %d, rows %d, row %d, r = %d\n", ControlID, seltext, rows, row, r);
|
||||
}
|
||||
|
||||
/** Mouse Button Up */
|
||||
@@ -822,13 +814,25 @@ void TextArea::OnMouseUp(unsigned short x, unsigned short y, unsigned short /*Bu
|
||||
RunEventHandler( TextAreaOnChange );
|
||||
}
|
||||
|
||||
/** Copies the current TextArea content to another TextArea control */
|
||||
void TextArea::CopyTo(TextArea* ta)
|
||||
void TextArea::SetText(const std::vector<char*>& text)
|
||||
{
|
||||
ta->Clear();
|
||||
for (size_t i = 0; i < lines.size(); i++) {
|
||||
ta->SetText( lines[i], -1 );
|
||||
Clear();
|
||||
for (size_t i = 0; i < text.size(); i++) {
|
||||
int newlen = strlen(text[i]);
|
||||
char* str = (char *) malloc(newlen + 1);
|
||||
memcpy(str, text[i], newlen + 1);
|
||||
lines.push_back(str);
|
||||
lrows.push_back(0);
|
||||
CurPos = newlen;
|
||||
}
|
||||
CurLine = lines.size() - 1;
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
/** Copies the current TextArea content to another TextArea control */
|
||||
void TextArea::CopyTo(TextArea *ta)
|
||||
{
|
||||
ta->SetText(lines);
|
||||
}
|
||||
|
||||
void TextArea::RedrawTextArea(const char* VariableName, unsigned int Sum)
|
||||
@@ -939,7 +943,7 @@ void TextArea::SetupScroll(unsigned long tck)
|
||||
}
|
||||
i = (unsigned int) lines.size();
|
||||
Flags |= IE_GUI_TEXTAREA_SMOOTHSCROLL;
|
||||
GetTime( starttime );
|
||||
starttime = GetTickCount();
|
||||
if (RunEventHandler( TextAreaOutOfText )) {
|
||||
//event handler destructed this object?
|
||||
return;
|
||||
|
||||
@@ -71,7 +71,9 @@ public:
|
||||
/** Set the TextArea value to the line number containing the string parameter */
|
||||
void SelectText(const char *select);
|
||||
/** Sets the Actual Text */
|
||||
int SetText(const char* text, int pos = 0);
|
||||
void SetText(const char* text);
|
||||
/** Sets text */
|
||||
void SetText(const std::vector<char*>& text);
|
||||
/** Clears the textarea */
|
||||
void Clear();
|
||||
/** Discards scrolled out lines from the textarea */
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
#include "Interface.h"
|
||||
#include "Palette.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
# include "SDL_uikitkeyboard.h"
|
||||
#endif
|
||||
|
||||
TextEdit::TextEdit(unsigned short maxLength, unsigned short px, unsigned short py)
|
||||
{
|
||||
@@ -71,6 +77,9 @@ void TextEdit::Draw(unsigned short x, unsigned short y)
|
||||
|
||||
//The aligning of textedit fields is done by absolute positioning (FontPosX, FontPosY)
|
||||
if (hasFocus) {
|
||||
#if TARGET_OS_IPHONE
|
||||
SDL_iPhoneKeyboardShow(SDL_GetWindowFromID(1));
|
||||
#endif
|
||||
font->Print( Region( x + XPos + FontPosX, y + YPos + FontPosY, Width, Height ), Buffer,
|
||||
palette, IE_FONT_ALIGN_LEFT | IE_FONT_ALIGN_TOP,
|
||||
true, NULL, Cursor, CurPos );
|
||||
@@ -184,7 +193,7 @@ void TextEdit::OnSpecialKeyPress(unsigned char Key)
|
||||
}
|
||||
|
||||
/** Sets the Text of the current control */
|
||||
int TextEdit::SetText(const char* string, int /*pos*/)
|
||||
void TextEdit::SetText(const char* string)
|
||||
{
|
||||
strncpy( ( char * ) Buffer, string, max );
|
||||
Buffer[max]=0;
|
||||
@@ -192,7 +201,6 @@ int TextEdit::SetText(const char* string, int /*pos*/)
|
||||
if (Owner) {
|
||||
Owner->Invalidate();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TextEdit::SetBufferLength(ieWord buflen)
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
/** Set BackGround */
|
||||
void SetBackGround(Sprite2D* back);
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char* string, int pos = 0);
|
||||
void SetText(const char* string);
|
||||
/** Sets the Text of the current control */
|
||||
const char* QueryText();
|
||||
/** Sets the buffer length */
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "GUI/Control.h"
|
||||
#include "GUI/MapControl.h"
|
||||
#include "GUI/Progressbar.h"
|
||||
#include "GUI/ScrollBar.h"
|
||||
#include "GUI/Slider.h"
|
||||
|
||||
#include "win32def.h"
|
||||
|
||||
@@ -29,15 +29,13 @@
|
||||
#define WINDOW_H
|
||||
|
||||
#include "GUI/Control.h"
|
||||
#include "GUI/ScrollBar.h"
|
||||
#include "GUI/TextArea.h"
|
||||
|
||||
#include "exports.h"
|
||||
|
||||
#include "Sprite2D.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Sprite2D;
|
||||
|
||||
// Window Flags
|
||||
#define WF_CHANGED 1 //window changed
|
||||
#define WF_FRAME 2 //window has frame
|
||||
|
||||
@@ -21,11 +21,14 @@
|
||||
|
||||
#include "win32def.h"
|
||||
|
||||
#include "Font.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "Interface.h"
|
||||
#include "Video.h"
|
||||
#include "WorldMap.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "GUI/Window.h"
|
||||
|
||||
#define MAP_TO_SCREENX(x) XWin + XPos - ScrollX + (x)
|
||||
#define MAP_TO_SCREENY(y) YWin + YPos - ScrollY + (y)
|
||||
@@ -341,10 +344,10 @@ void WorldMapControl::OnSpecialKeyPress(unsigned char Key)
|
||||
ScrollY += 64;
|
||||
break;
|
||||
case GEM_ALT:
|
||||
printf( "ALT pressed\n" );
|
||||
print( "ALT pressed\n" );
|
||||
break;
|
||||
case GEM_TAB:
|
||||
printf( "TAB pressed\n" );
|
||||
print( "TAB pressed\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,6 @@ public:
|
||||
void Draw(unsigned short x, unsigned short y);
|
||||
/** Sets the exit direction (we need this to calculate distances) */
|
||||
void SetDirection(int direction);
|
||||
/** Sets the Text of the current control */
|
||||
int SetText(const char* /*string*/, int /*pos*/) { return 0; }
|
||||
/** Set color for one type of area labels */
|
||||
void SetColor(int which, Color color);
|
||||
int ScrollX, ScrollY;
|
||||
|
||||
@@ -29,10 +29,13 @@
|
||||
#include "DisplayMessage.h"
|
||||
#include "GameData.h"
|
||||
#include "Interface.h"
|
||||
#include "IniSpawn.h"
|
||||
#include "MapMgr.h"
|
||||
#include "MusicMgr.h"
|
||||
#include "Particles.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "ScriptEngine.h"
|
||||
#include "TableMgr.h"
|
||||
#include "GameScript/GameScript.h"
|
||||
#include "GUI/GameControl.h"
|
||||
#include "System/DataStream.h"
|
||||
@@ -149,7 +152,7 @@ Game::~Game(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool IsAlive(Actor *pc)
|
||||
static bool IsAlive(Actor *pc)
|
||||
{
|
||||
if (pc->GetStat(IE_STATE_ID)&STATE_DEAD) {
|
||||
return false;
|
||||
@@ -312,6 +315,8 @@ void Game::ConsolidateParty()
|
||||
}
|
||||
for ( m = PCs.begin(); m != PCs.end(); ++m) {
|
||||
(*m)->RefreshEffects(NULL);
|
||||
//TODO: how to set up bardsongs
|
||||
(*m)->SetModalSpell((*m)->ModalState, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,8 +374,7 @@ void Game::InitActorPos(Actor *actor)
|
||||
AutoTable strta("startpos");
|
||||
|
||||
if (!start || !strta) {
|
||||
printMessage("Game","Game is missing character start data.\n",RED);
|
||||
abort();
|
||||
error("Game", "Game is missing character start data.\n");
|
||||
}
|
||||
// 0 - single player, 1 - tutorial, 2 - expansion
|
||||
ieDword playmode = 0;
|
||||
@@ -475,7 +479,7 @@ void Game::SetHotKey(unsigned long Key)
|
||||
Actor *actor = *m;
|
||||
|
||||
if (actor->IsSelected()) {
|
||||
actor->HotKey = (ieDword) Key;
|
||||
actor->AddTrigger(TriggerEntry(trigger_hotkey, (ieDword) Key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -769,7 +773,7 @@ int Game::LoadMap(const char* ResRef, bool loadscreen)
|
||||
if (!ds) {
|
||||
goto failedload;
|
||||
}
|
||||
if(!mM->Open( ds, true )) {
|
||||
if(!mM->Open(ds)) {
|
||||
goto failedload;
|
||||
}
|
||||
newMap = mM->GetMap(ResRef, IsDay());
|
||||
@@ -1021,7 +1025,7 @@ int Game::GetXPFromCR(int cr)
|
||||
if (cr>=MAX_CRLEVEL) {
|
||||
cr=MAX_CRLEVEL-1;
|
||||
}
|
||||
printf("Challenge Rating: %d, party level: %d ", cr, level);
|
||||
print("Challenge Rating: %d, party level: %d ", cr, level);
|
||||
return crtable[level][cr];
|
||||
}
|
||||
printMessage("Game","Cannot find moncrate.2da!\n", LIGHT_RED);
|
||||
@@ -1097,7 +1101,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);
|
||||
print("Actor %s is not near!\n", PCs[i]->LongName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1124,17 +1128,6 @@ void Game::PartyMemberDied(Actor *actor)
|
||||
}
|
||||
}
|
||||
|
||||
//reports if someone died
|
||||
int Game::PartyMemberDied() const
|
||||
{
|
||||
for (unsigned int i=0; i<PCs.size(); i++) {
|
||||
if (PCs[i]->GetInternalFlag()&IF_JUSTDIED) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Game::IncrementChapter()
|
||||
{
|
||||
//chapter first set to 0 (prologue)
|
||||
@@ -1285,8 +1278,7 @@ bool Game::EveryoneDead() const
|
||||
|
||||
void Game::UpdateScripts()
|
||||
{
|
||||
ExecuteScript( 1 );
|
||||
ProcessActions(false);
|
||||
Update();
|
||||
size_t idx;
|
||||
|
||||
PartyAttack = false;
|
||||
@@ -1524,7 +1516,19 @@ void Game::RestParty(int checks, int dream, int hp)
|
||||
void Game::TimeStop(Actor* owner, ieDword end)
|
||||
{
|
||||
timestop_owner=owner;
|
||||
timestop_end=GameTime+end;
|
||||
timestop_end=end;
|
||||
}
|
||||
|
||||
// check if the passed actor is a victim of timestop
|
||||
bool Game::TimeStoppedFor(const Actor* target)
|
||||
{
|
||||
if (!timestop_owner) {
|
||||
return false;
|
||||
}
|
||||
if (target == timestop_owner || target->GetStat(IE_DISABLETIMESTOP)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//recalculate the party's infravision state
|
||||
@@ -1549,7 +1553,6 @@ void Game::Infravision()
|
||||
//returns the colour which should be applied onto the whole game area viewport
|
||||
//this is based on timestop, dream area, weather, daytime
|
||||
|
||||
static const Color TimeStopTint={0xe0,0xe0,0xe0,0x20}; //greyscale
|
||||
static const Color DreamTint={0xf0,0xe0,0xd0,0x10}; //light brown scale
|
||||
static const Color NightTint={0x80,0x80,0xe0,0x40}; //dark, bluish
|
||||
static const Color DuskTint={0xe0,0x80,0x80,0x40}; //dark, reddish
|
||||
@@ -1558,9 +1561,6 @@ static const Color DarkTint={0x80,0x80,0xe0,0x10}; //slightly dark bluish
|
||||
|
||||
const Color *Game::GetGlobalTint() const
|
||||
{
|
||||
if (timestop_end>GameTime) {
|
||||
return &TimeStopTint;
|
||||
}
|
||||
Map *map = GetCurrentArea();
|
||||
if (!map) return NULL;
|
||||
if (map->AreaFlags&AF_DREAM) {
|
||||
@@ -1617,7 +1617,7 @@ void Game::ChangeSong(bool always, bool force)
|
||||
}
|
||||
|
||||
/* this method redraws weather. If update is false,
|
||||
then the weather particles won't change (game paused)
|
||||
then the weather particles won't change (game paused)
|
||||
*/
|
||||
void Game::DrawWeather(const Region &screen, bool update)
|
||||
{
|
||||
@@ -1717,21 +1717,21 @@ void Game::DebugDump()
|
||||
{
|
||||
size_t idx;
|
||||
|
||||
printf("Currently loaded areas:\n");
|
||||
print("Currently loaded areas:\n");
|
||||
for(idx=0;idx<Maps.size();idx++) {
|
||||
Map *map = Maps[idx];
|
||||
|
||||
printf("%s\n",map->GetScriptName());
|
||||
print("%s\n",map->GetScriptName());
|
||||
}
|
||||
printf("Current area: %s Previous area: %s\n", CurrentArea, PreviousArea);
|
||||
printf("Global script: %s\n", Scripts[0]->GetName());
|
||||
printf("CombatCounter: %d\n", (int) CombatCounter);
|
||||
print("Current area: %s Previous area: %s\n", CurrentArea, PreviousArea);
|
||||
print("Global script: %s\n", Scripts[0]->GetName());
|
||||
print("CombatCounter: %d\n", (int) CombatCounter);
|
||||
|
||||
printf("Party size: %d\n", (int) PCs.size());
|
||||
print("Party size: %d\n", (int) PCs.size());
|
||||
for(idx=0;idx<PCs.size();idx++) {
|
||||
Actor *actor = PCs[idx];
|
||||
|
||||
printf("Name: %s Order %d %s\n",actor->ShortName, actor->InParty, actor->Selected?"x":"-");
|
||||
print("Name: %s Order %d %s\n",actor->ShortName, actor->InParty, actor->Selected?"x":"-");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1755,3 +1755,7 @@ ieByte *Game::AllocateMazeData()
|
||||
return mazedata;
|
||||
}
|
||||
|
||||
bool Game::IsTimestopActive()
|
||||
{
|
||||
return timestop_end > GameTime;
|
||||
}
|
||||
|
||||
@@ -34,13 +34,16 @@ class Game;
|
||||
#include "ie_types.h"
|
||||
|
||||
#include "Callback.h"
|
||||
#include "Map.h"
|
||||
#include "Scriptable/Scriptable.h"
|
||||
#include "Scriptable/PCStatStruct.h"
|
||||
#include "Variables.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Actor;
|
||||
class Map;
|
||||
class Particles;
|
||||
class TableMgr;
|
||||
|
||||
//the size of the bestiary register
|
||||
#define BESTIARY_SIZE 260
|
||||
@@ -420,8 +423,6 @@ public:
|
||||
/** returns true if no one moves */
|
||||
bool EveryoneStopped() const;
|
||||
bool EveryoneNearPoint(Map *map, const Point &p, int flags) const;
|
||||
/** returns true if a PC just died */
|
||||
int PartyMemberDied() const;
|
||||
/** a party member just died now */
|
||||
void PartyMemberDied(Actor *);
|
||||
/** Increments chapter variable and refreshes kill stats */
|
||||
@@ -449,6 +450,8 @@ public:
|
||||
void RestParty(int checks, int dream, int hp);
|
||||
/** timestop effect initiated by actor */
|
||||
void TimeStop(Actor *actor, ieDword end);
|
||||
/** check if the passed actor is a victim of timestop */
|
||||
bool TimeStoppedFor(const Actor* target=NULL);
|
||||
/** updates the infravision info */
|
||||
void Infravision();
|
||||
/** gets the colour which should be applied over the game area,
|
||||
@@ -468,6 +471,8 @@ public:
|
||||
Actor *GetActorByGlobalID(ieDword objectID);
|
||||
/** Allocates maze data */
|
||||
ieByte *AllocateMazeData();
|
||||
/** Checks if any timestop effects are active */
|
||||
bool IsTimestopActive();
|
||||
private:
|
||||
bool DetermineStartPosType(const TableMgr *strta);
|
||||
ieResRef *GetDream(Map *area);
|
||||
|
||||
@@ -20,9 +20,12 @@
|
||||
|
||||
#include "GameData.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "ActorMgr.h"
|
||||
#include "AnimationMgr.h"
|
||||
#include "Cache.h"
|
||||
#include "CharAnimations.h"
|
||||
#include "Effect.h"
|
||||
#include "EffectMgr.h"
|
||||
#include "Factory.h"
|
||||
@@ -32,9 +35,12 @@
|
||||
#include "Interface.h"
|
||||
#include "Item.h"
|
||||
#include "ItemMgr.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "ResourceDesc.h"
|
||||
#include "ScriptedAnimation.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "StoreMgr.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
#include "System/FileStream.h"
|
||||
|
||||
@@ -90,7 +96,7 @@ Actor *GameData::GetCreature(const char* ResRef, unsigned int PartySlot)
|
||||
return 0;
|
||||
|
||||
PluginHolder<ActorMgr> actormgr(IE_CRE_CLASS_ID);
|
||||
if (!actormgr->Open( ds, true )) {
|
||||
if (!actormgr->Open(ds)) {
|
||||
return 0;
|
||||
}
|
||||
Actor* actor = actormgr->GetActor(PartySlot);
|
||||
@@ -106,11 +112,9 @@ int GameData::LoadCreature(const char* ResRef, unsigned int PartySlot, bool char
|
||||
char nPath[_MAX_PATH], fName[16];
|
||||
snprintf( fName, sizeof(fName), "%s.chr", ResRef);
|
||||
PathJoin( nPath, core->GamePath, "characters", fName, NULL );
|
||||
FileStream *fs = new FileStream();
|
||||
fs -> Open( nPath, true );
|
||||
stream = (DataStream *) fs;
|
||||
stream = FileStream::OpenFile(nPath);
|
||||
PluginHolder<ActorMgr> actormgr(IE_CRE_CLASS_ID);
|
||||
if (!actormgr->Open( stream, true )) {
|
||||
if (!actormgr->Open(stream)) {
|
||||
return -1;
|
||||
}
|
||||
actor = actormgr->GetActor(PartySlot);
|
||||
@@ -151,7 +155,7 @@ int GameData::LoadTable(const ieResRef ResRef)
|
||||
tables[ind].refcount++;
|
||||
return ind;
|
||||
}
|
||||
//printf("(%s) Table not found... Loading from file\n", ResRef);
|
||||
//print("(%s) Table not found... Loading from file\n", ResRef);
|
||||
DataStream* str = GetResource( ResRef, IE_2DA_CLASS_ID );
|
||||
if (!str) {
|
||||
return -1;
|
||||
@@ -161,7 +165,7 @@ int GameData::LoadTable(const ieResRef ResRef)
|
||||
delete str;
|
||||
return -1;
|
||||
}
|
||||
if (!tm->Open( str, true )) {
|
||||
if (!tm->Open(str)) {
|
||||
return -1;
|
||||
}
|
||||
Table t;
|
||||
@@ -257,8 +261,7 @@ void GameData::FreePalette(Palette *&pal, const ieResRef name)
|
||||
}
|
||||
if (!name || !name[0]) {
|
||||
if(pal->named) {
|
||||
printf("Palette is supposed to be named, but got no name!\n");
|
||||
abort();
|
||||
error("GameData", "Palette is supposed to be named, but got no name!\n");
|
||||
} else {
|
||||
pal->Release();
|
||||
pal=NULL;
|
||||
@@ -266,14 +269,11 @@ void GameData::FreePalette(Palette *&pal, const ieResRef name)
|
||||
return;
|
||||
}
|
||||
if (!pal->named) {
|
||||
printf("Unnamed palette, it should be %s!\n", name);
|
||||
abort();
|
||||
error("GameData", "Unnamed palette, it should be %s!\n", name);
|
||||
}
|
||||
res=PaletteCache.DecRef((void *) pal, name, true);
|
||||
if (res<0) {
|
||||
printMessage( "Core", "Corrupted Palette cache encountered (reference count went below zero), ", LIGHT_RED );
|
||||
printf( "Palette name is: %.8s\n", name);
|
||||
abort();
|
||||
error("Core", "Corrupted Palette cache encountered (reference count went below zero), Palette name is: %.8s\n", name);
|
||||
}
|
||||
if (!res) {
|
||||
pal->Release();
|
||||
@@ -293,7 +293,7 @@ Item* GameData::GetItem(const ieResRef resname)
|
||||
delete ( str );
|
||||
return NULL;
|
||||
}
|
||||
if (!sm->Open( str, true )) {
|
||||
if (!sm->Open(str)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -316,9 +316,7 @@ void GameData::FreeItem(Item const *itm, const ieResRef name, bool free)
|
||||
|
||||
res=ItemCache.DecRef((void *) itm, name, free);
|
||||
if (res<0) {
|
||||
printMessage( "Core", "Corrupted Item cache encountered (reference count went below zero), ", LIGHT_RED );
|
||||
printf( "Item name is: %.8s\n", name);
|
||||
abort();
|
||||
error("Core", "Corrupted Item cache encountered (reference count went below zero), Item name is: %.8s\n", name);
|
||||
}
|
||||
if (res) return;
|
||||
if (free) delete itm;
|
||||
@@ -336,7 +334,7 @@ Spell* GameData::GetSpell(const ieResRef resname, bool silent)
|
||||
delete ( str );
|
||||
return NULL;
|
||||
}
|
||||
if (!sm->Open( str, true )) {
|
||||
if (!sm->Open(str)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -358,8 +356,8 @@ void GameData::FreeSpell(Spell *spl, const ieResRef name, bool free)
|
||||
|
||||
res=SpellCache.DecRef((void *) spl, name, free);
|
||||
if (res<0) {
|
||||
printMessage( "Core", "Corrupted Spell cache encountered (reference count went below zero), ", LIGHT_RED );
|
||||
printf( "Spell name is: %.8s or %.8s\n", name, spl->Name);
|
||||
printMessage("Core", "Corrupted Spell cache encountered (reference count went below zero), Spell name is: %.8s or %.8s\n", LIGHT_RED,
|
||||
name, spl->Name);
|
||||
abort();
|
||||
}
|
||||
if (res) return;
|
||||
@@ -378,7 +376,7 @@ Effect* GameData::GetEffect(const ieResRef resname)
|
||||
delete ( str );
|
||||
return NULL;
|
||||
}
|
||||
if (!em->Open( str, true )) {
|
||||
if (!em->Open(str)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -397,9 +395,7 @@ void GameData::FreeEffect(Effect *eff, const ieResRef name, bool free)
|
||||
|
||||
res=EffectCache.DecRef((void *) eff, name, free);
|
||||
if (res<0) {
|
||||
printMessage( "Core", "Corrupted Effect cache encountered (reference count went below zero), ", LIGHT_RED );
|
||||
printf( "Effect name is: %.8s\n", name);
|
||||
abort();
|
||||
error("Core", "Corrupted Effect cache encountered (reference count went below zero), Effect name is: %.8s\n", name);
|
||||
}
|
||||
if (res) return;
|
||||
if (free) delete eff;
|
||||
@@ -413,7 +409,7 @@ ScriptedAnimation* GameData::GetScriptedAnimation( const char *effect, bool doub
|
||||
|
||||
if (Exists( effect, IE_VVC_CLASS_ID, true ) ) {
|
||||
DataStream *ds = GetResource( effect, IE_VVC_CLASS_ID );
|
||||
ret = new ScriptedAnimation(ds, true);
|
||||
ret = new ScriptedAnimation(ds);
|
||||
} else {
|
||||
AnimationFactory *af = (AnimationFactory *)
|
||||
GetFactoryResource( effect, IE_BAM_CLASS_ID, IE_NORMAL );
|
||||
@@ -463,7 +459,8 @@ void* GameData::GetFactoryResource(const char* resname, SClass_ID type,
|
||||
PluginHolder<AnimationMgr> ani(IE_BAM_CLASS_ID);
|
||||
if (!ani)
|
||||
return NULL;
|
||||
ani->Open( ret, true );
|
||||
if (!ani->Open(ret))
|
||||
return NULL;
|
||||
AnimationFactory* af = ani->GetAnimationFactory( resname, mode );
|
||||
factory->AddFactoryObject( af );
|
||||
return af;
|
||||
@@ -482,9 +479,71 @@ void* GameData::GetFactoryResource(const char* resname, SClass_ID type,
|
||||
return NULL;
|
||||
}
|
||||
default:
|
||||
printf( "\n" );
|
||||
printMessage( "KEYImporter", " ", WHITE );
|
||||
printf( "%s files are not supported.\n", core->TypeExt( type ) );
|
||||
print( "\n" );
|
||||
printMessage("KEYImporter", "%s files are not supported.\n", WHITE,
|
||||
core->TypeExt(type));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Store* GameData::GetStore(const ieResRef ResRef)
|
||||
{
|
||||
StoreMap::iterator it = stores.find(ResRef);
|
||||
if (it != stores.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
DataStream* str = gamedata->GetResource(ResRef, IE_STO_CLASS_ID);
|
||||
PluginHolder<StoreMgr> sm(IE_STO_CLASS_ID);
|
||||
if (sm == NULL) {
|
||||
delete ( str );
|
||||
return NULL;
|
||||
}
|
||||
if (!sm->Open(str)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Store* store = sm->GetStore(new Store());
|
||||
if (store == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strnlwrcpy(store->Name, ResRef, 8);
|
||||
// The key needs to last as long as the store,
|
||||
// so use the one we just copied.
|
||||
stores[store->Name] = store;
|
||||
return store;
|
||||
}
|
||||
|
||||
void GameData::SaveStore(Store* store)
|
||||
{
|
||||
if (!store)
|
||||
return;
|
||||
StoreMap::iterator it = stores.find(store->Name);
|
||||
if (it == stores.end()) {
|
||||
error("GameData", "Saving a store that wasn't cached.");
|
||||
}
|
||||
|
||||
PluginHolder<StoreMgr> sm(IE_STO_CLASS_ID);
|
||||
if (sm == NULL) {
|
||||
error("GameData", "Can't save store to cache.");
|
||||
}
|
||||
|
||||
FileStream str;
|
||||
|
||||
if (!str.Create(store->Name, IE_STO_CLASS_ID)) {
|
||||
error("GameData", "Can't create file while saving store.");
|
||||
}
|
||||
if (!sm->PutStore(&str, store)) {
|
||||
error("GameData", "Error saving store.");
|
||||
}
|
||||
|
||||
stores.erase(it);
|
||||
delete store;
|
||||
}
|
||||
|
||||
void GameData::SaveAllStores()
|
||||
{
|
||||
while (!stores.empty()) {
|
||||
SaveStore(stores.begin()->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,19 @@
|
||||
#include "SClassID.h"
|
||||
#include "exports.h"
|
||||
#include "ie_types.h"
|
||||
#include "iless.h"
|
||||
|
||||
#include "Cache.h"
|
||||
#include "Holder.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _MSC_VER // No SFINAE
|
||||
#include "TableMgr.h"
|
||||
#endif
|
||||
|
||||
class Actor;
|
||||
struct Effect;
|
||||
class Factory;
|
||||
@@ -38,6 +46,7 @@ class ScriptedAnimation;
|
||||
class Spell;
|
||||
class Sprite2D;
|
||||
class TableMgr;
|
||||
class Store;
|
||||
|
||||
struct Table {
|
||||
Holder<TableMgr> tm;
|
||||
@@ -90,6 +99,12 @@ public:
|
||||
/** returns factory resource, currently works only with animations */
|
||||
void* GetFactoryResource(const char* resname, SClass_ID type,
|
||||
unsigned char mode = IE_NORMAL, bool silent=false);
|
||||
|
||||
Store* GetStore(const ieResRef ResRef);
|
||||
/// Saves a store to the cache and frees it.
|
||||
void SaveStore(Store* store);
|
||||
/// Saves all stores in the cache
|
||||
void SaveAllStores();
|
||||
private:
|
||||
Cache ItemCache;
|
||||
Cache SpellCache;
|
||||
@@ -97,6 +112,8 @@ private:
|
||||
Cache PaletteCache;
|
||||
Factory* factory;
|
||||
std::vector<Table> tables;
|
||||
typedef std::map<const char*, Store*, iless> StoreMap;
|
||||
StoreMap stores;
|
||||
};
|
||||
|
||||
extern GEM_EXPORT GameData * gamedata;
|
||||
|
||||
@@ -27,11 +27,14 @@
|
||||
|
||||
#include "AmbientMgr.h"
|
||||
#include "Audio.h"
|
||||
#include "CharAnimations.h"
|
||||
#include "DataFileMgr.h"
|
||||
#include "DialogHandler.h"
|
||||
#include "DisplayMessage.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "IniSpawn.h"
|
||||
#include "Item.h"
|
||||
#include "Map.h"
|
||||
#include "MusicMgr.h"
|
||||
@@ -41,6 +44,7 @@
|
||||
#include "Video.h"
|
||||
#include "WorldMap.h"
|
||||
#include "GUI/GameControl.h"
|
||||
#include "GUI/EventMgr.h"
|
||||
#include "Scriptable/Container.h"
|
||||
#include "Scriptable/Door.h"
|
||||
#include "Scriptable/InfoPoint.h"
|
||||
@@ -457,7 +461,7 @@ void GameScript::TriggerActivation(Scriptable* Sender, Action* parameters)
|
||||
ip = Sender->GetCurrentArea()->TMap->GetInfoPoint(parameters->objects[1]->objectName);
|
||||
}
|
||||
if (!ip || (ip->Type!=ST_TRIGGER && ip->Type!=ST_TRAVEL && ip->Type!=ST_PROXIMITY)) {
|
||||
printf("Script error: No Trigger Named \"%s\"\n", parameters->objects[1]->objectName);
|
||||
print("Script error: No Trigger Named \"%s\"\n", parameters->objects[1]->objectName);
|
||||
return;
|
||||
}
|
||||
InfoPoint *trigger = (InfoPoint *) ip;
|
||||
@@ -578,7 +582,7 @@ void GameScript::ExitPocketPlane(Scriptable* /*Sender*/, Action* /*parameters*/)
|
||||
if (act) {
|
||||
if (game->GetPlaneLocationCount() <= (unsigned int)i) {
|
||||
// what are we meant to do here?
|
||||
printf("argh, couldn't restore party member %d!", i + 1);
|
||||
print("argh, couldn't restore party member %d!", i + 1);
|
||||
continue;
|
||||
}
|
||||
GAMLocationEntry *gle = game->GetPlaneLocationEntry(i);
|
||||
@@ -678,7 +682,7 @@ void GameScript::CreateCreatureObjectDoor(Scriptable* Sender, Action* parameters
|
||||
{
|
||||
//we hack this to death
|
||||
strcpy(parameters->string1Parameter, "SPDIMNDR");
|
||||
CreateCreatureCore( Sender, parameters, CC_OFFSET | CC_CHECK_IMPASSABLE|CC_CHECK_OVERLAP | CC_PLAY_ANIM );
|
||||
CreateCreatureCore( Sender, parameters, CC_OBJECT | CC_CHECK_IMPASSABLE|CC_CHECK_OVERLAP | CC_PLAY_ANIM );
|
||||
}
|
||||
|
||||
//don't use offset from Sender
|
||||
@@ -1126,13 +1130,10 @@ void GameScript::MoveToPoint(Scriptable* Sender, Action* parameters)
|
||||
return;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
//InMove can clear destination, so we need to save it
|
||||
Point dest = actor->Destination;
|
||||
|
||||
// try the actual move, if we are not already moving there
|
||||
if (!actor->InMove() || actor->Destination != parameters->pointParameter) {
|
||||
actor->WalkTo( parameters->pointParameter, 0 );
|
||||
dest = actor->Destination;
|
||||
}
|
||||
|
||||
// give up if we can't move there (no path was found)
|
||||
@@ -1308,7 +1309,7 @@ void GameScript::RestorePartyLocation(Scriptable* /*Sender*/, Action* /*paramete
|
||||
if (act) {
|
||||
if (game->GetSavedLocationCount() <= (unsigned int)i) {
|
||||
// what are we meant to do here?
|
||||
printf("argh, couldn't restore party member %d!", i + 1);
|
||||
print("argh, couldn't restore party member %d!", i + 1);
|
||||
continue;
|
||||
}
|
||||
GAMLocationEntry *gle = game->GetSavedLocationEntry(i);
|
||||
@@ -1523,7 +1524,7 @@ void GameScript::DisplayStringHead(Scriptable* Sender, Action* parameters)
|
||||
Scriptable* target = GetActorFromObject( Sender, parameters->objects[1] );
|
||||
if (!target) {
|
||||
target=Sender;
|
||||
printf("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
print("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
}
|
||||
|
||||
DisplayStringCore(target, parameters->int0Parameter, DS_CONSOLE|DS_HEAD|DS_SPEECH );
|
||||
@@ -1556,7 +1557,7 @@ void GameScript::FloatMessageFixed(Scriptable* Sender, Action* parameters)
|
||||
Scriptable* target = GetActorFromObject( Sender, parameters->objects[1] );
|
||||
if (!target) {
|
||||
target=Sender;
|
||||
printf("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
print("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
}
|
||||
|
||||
DisplayStringCore(target, parameters->int0Parameter, DS_CONSOLE|DS_HEAD);
|
||||
@@ -1567,7 +1568,7 @@ void GameScript::FloatMessageFixedRnd(Scriptable* Sender, Action* parameters)
|
||||
Scriptable* target = GetActorFromObject( Sender, parameters->objects[1] );
|
||||
if (!target) {
|
||||
target=Sender;
|
||||
printf("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
print("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
}
|
||||
|
||||
SrcVector *rndstr=LoadSrc(parameters->string0Parameter);
|
||||
@@ -1584,7 +1585,7 @@ void GameScript::FloatMessageRnd(Scriptable* Sender, Action* parameters)
|
||||
Scriptable* target = GetActorFromObject( Sender, parameters->objects[1] );
|
||||
if (!target) {
|
||||
target=Sender;
|
||||
printf("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
print("DisplayStringHead/FloatMessage got no target, assuming Sender!\n");
|
||||
}
|
||||
|
||||
SrcVector *rndstr=LoadSrc(parameters->string0Parameter);
|
||||
@@ -1770,20 +1771,20 @@ void GameScript::SetMusic(Scriptable* Sender, Action* parameters)
|
||||
//optional integer parameter (isSpeech)
|
||||
void GameScript::PlaySound(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
printf( "PlaySound(%s)\n", parameters->string0Parameter );
|
||||
print( "PlaySound(%s)\n", parameters->string0Parameter );
|
||||
core->GetAudioDrv()->Play( parameters->string0Parameter, Sender->Pos.x,
|
||||
Sender->Pos.y, parameters->int0Parameter ? GEM_SND_SPEECH : 0 );
|
||||
}
|
||||
|
||||
void GameScript::PlaySoundPoint(Scriptable* /*Sender*/, Action* parameters)
|
||||
{
|
||||
printf( "PlaySound(%s)\n", parameters->string0Parameter );
|
||||
print( "PlaySound(%s)\n", parameters->string0Parameter );
|
||||
core->GetAudioDrv()->Play( parameters->string0Parameter, parameters->pointParameter.x, parameters->pointParameter.y );
|
||||
}
|
||||
|
||||
void GameScript::PlaySoundNotRanged(Scriptable* /*Sender*/, Action* parameters)
|
||||
{
|
||||
printf( "PlaySound(%s)\n", parameters->string0Parameter );
|
||||
print( "PlaySound(%s)\n", parameters->string0Parameter );
|
||||
core->GetAudioDrv()->Play( parameters->string0Parameter, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1903,7 +1904,7 @@ void GameScript::AmbientActivate(Scriptable* Sender, Action* parameters)
|
||||
anim = Sender->GetCurrentArea( )->GetAnimation( parameters->objects[1]->objectName );
|
||||
}
|
||||
if (!anim) {
|
||||
printf( "Script error: No Animation Named \"%s\" or \"%s\"\n",
|
||||
print( "Script error: No Animation Named \"%s\" or \"%s\"\n",
|
||||
parameters->string0Parameter,parameters->objects[1]->objectName );
|
||||
return;
|
||||
}
|
||||
@@ -1934,7 +1935,7 @@ void GameScript::StaticStart(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
AreaAnimation *anim = Sender->GetCurrentArea()->GetAnimation(parameters->objects[1]->objectName);
|
||||
if (!anim) {
|
||||
printf( "Script error: No Animation Named \"%s\"\n",
|
||||
print( "Script error: No Animation Named \"%s\"\n",
|
||||
parameters->objects[1]->objectName );
|
||||
return;
|
||||
}
|
||||
@@ -1945,7 +1946,7 @@ void GameScript::StaticStop(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
AreaAnimation *anim = Sender->GetCurrentArea()->GetAnimation(parameters->objects[1]->objectName);
|
||||
if (!anim) {
|
||||
printf( "Script error: No Animation Named \"%s\"\n",
|
||||
print( "Script error: No Animation Named \"%s\"\n",
|
||||
parameters->objects[1]->objectName );
|
||||
return;
|
||||
}
|
||||
@@ -1956,7 +1957,7 @@ void GameScript::StaticPalette(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
AreaAnimation *anim = Sender->GetCurrentArea()->GetAnimation(parameters->objects[1]->objectName);
|
||||
if (!anim) {
|
||||
printf( "Script error: No Animation Named \"%s\"\n",
|
||||
print( "Script error: No Animation Named \"%s\"\n",
|
||||
parameters->objects[1]->objectName );
|
||||
return;
|
||||
}
|
||||
@@ -2146,7 +2147,7 @@ void GameScript::NIDSpecial2(Scriptable* Sender, Action* /*parameters*/)
|
||||
}
|
||||
//travel direction passed to guiscript
|
||||
int direction = Sender->GetCurrentArea()->WhichEdge(actor->Pos);
|
||||
printf("Travel direction returned: %d\n", direction);
|
||||
print("Travel direction returned: %d\n", direction);
|
||||
if (direction==-1) {
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
@@ -2565,16 +2566,16 @@ void GameScript::Spell(Scriptable* Sender, Action* parameters)
|
||||
return;
|
||||
}
|
||||
|
||||
//if target was set, fire spell
|
||||
if (Sender->LastTarget) {
|
||||
Sender->CastSpellEnd(0);
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
|
||||
//the target was converted to a point
|
||||
if(!Sender->LastTargetPos.isempty()) {
|
||||
Sender->CastSpellPointEnd(0);
|
||||
if (Sender->CurrentActionState) {
|
||||
if (Sender->LastTarget) {
|
||||
//if target was set, fire spell
|
||||
Sender->CastSpellEnd(0);
|
||||
} else if(!Sender->LastTargetPos.isempty()) {
|
||||
//the target was converted to a point
|
||||
Sender->CastSpellPointEnd(0);
|
||||
} else {
|
||||
printMessage("GameScript", "Spell lost target somewhere!", LIGHT_RED);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
@@ -2613,6 +2614,7 @@ void GameScript::Spell(Scriptable* Sender, Action* parameters)
|
||||
//stop doing anything else
|
||||
act->SetModal(MS_NONE);
|
||||
}
|
||||
Sender->CurrentActionState = 1;
|
||||
int duration = Sender->CastSpell( spellres, tar, true );
|
||||
if (duration != -1) Sender->SetWait(duration);
|
||||
|
||||
@@ -2634,9 +2636,13 @@ void GameScript::SpellPoint(Scriptable* Sender, Action* parameters)
|
||||
return;
|
||||
}
|
||||
|
||||
//if target was set, fire spell
|
||||
if (!Sender->LastTargetPos.isempty()) {
|
||||
Sender->CastSpellPointEnd(0);
|
||||
if (Sender->CurrentActionState) {
|
||||
if(!Sender->LastTargetPos.isempty()) {
|
||||
//if target was set, fire spell
|
||||
Sender->CastSpellPointEnd(0);
|
||||
} else {
|
||||
printMessage("GameScript", "SpellPoint lost target somewhere!", LIGHT_RED);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
@@ -2657,6 +2663,7 @@ void GameScript::SpellPoint(Scriptable* Sender, Action* parameters)
|
||||
act->SetModal(MS_NONE);
|
||||
}
|
||||
|
||||
Sender->CurrentActionState = 1;
|
||||
int duration = Sender->CastSpellPoint( spellres, parameters->pointParameter, true );
|
||||
if (duration != -1) Sender->SetWait(duration);
|
||||
|
||||
@@ -2683,16 +2690,16 @@ void GameScript::SpellNoDec(Scriptable* Sender, Action* parameters)
|
||||
}
|
||||
}
|
||||
|
||||
//if target was set, fire spell
|
||||
if (Sender->LastTarget) {
|
||||
Sender->CastSpellEnd(0);
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
|
||||
//the target was converted to a point
|
||||
if(!Sender->LastTargetPos.isempty()) {
|
||||
Sender->CastSpellPointEnd(0);
|
||||
if (Sender->CurrentActionState) {
|
||||
if (Sender->LastTarget) {
|
||||
//if target was set, fire spell
|
||||
Sender->CastSpellEnd(0);
|
||||
} else if(!Sender->LastTargetPos.isempty()) {
|
||||
//the target was converted to a point
|
||||
Sender->CastSpellPointEnd(0);
|
||||
} else {
|
||||
printMessage("GameScript", "SpellNoDec lost target somewhere!", LIGHT_RED);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
@@ -2714,6 +2721,7 @@ void GameScript::SpellNoDec(Scriptable* Sender, Action* parameters)
|
||||
//stop doing anything else
|
||||
act->SetModal(MS_NONE);
|
||||
}
|
||||
Sender->CurrentActionState = 1;
|
||||
int duration = Sender->CastSpell( spellres, tar, false );
|
||||
if (duration != -1) Sender->SetWait(duration);
|
||||
|
||||
@@ -2740,9 +2748,13 @@ void GameScript::SpellPointNoDec(Scriptable* Sender, Action* parameters)
|
||||
}
|
||||
}
|
||||
|
||||
//if target was set, fire spell
|
||||
if (!Sender->LastTargetPos.isempty()) {
|
||||
Sender->CastSpellPointEnd(0);
|
||||
if (Sender->CurrentActionState) {
|
||||
if(!Sender->LastTargetPos.isempty()) {
|
||||
//if target was set, fire spell
|
||||
Sender->CastSpellPointEnd(0);
|
||||
} else {
|
||||
printMessage("GameScript", "SpellPointNoDec lost target somewhere!", LIGHT_RED);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
@@ -2756,6 +2768,7 @@ void GameScript::SpellPointNoDec(Scriptable* Sender, Action* parameters)
|
||||
act->SetModal(MS_NONE);
|
||||
}
|
||||
|
||||
Sender->CurrentActionState = 1;
|
||||
int duration = Sender->CastSpellPoint( spellres, parameters->pointParameter, false );
|
||||
if (duration != -1) Sender->SetWait(duration);
|
||||
|
||||
@@ -2782,16 +2795,16 @@ void GameScript::ForceSpell(Scriptable* Sender, Action* parameters)
|
||||
}
|
||||
}
|
||||
|
||||
//if target was set, fire spell
|
||||
if (Sender->LastTarget) {
|
||||
Sender->CastSpellEnd(0);
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
|
||||
//the target was converted to a point
|
||||
if(!Sender->LastTargetPos.isempty()) {
|
||||
Sender->CastSpellPointEnd(0);
|
||||
if (Sender->CurrentActionState) {
|
||||
if (Sender->LastTarget) {
|
||||
//if target was set, fire spell
|
||||
Sender->CastSpellEnd(0);
|
||||
} else if(!Sender->LastTargetPos.isempty()) {
|
||||
//the target was converted to a point
|
||||
Sender->CastSpellPointEnd(0);
|
||||
} else {
|
||||
printMessage("GameScript", "ForceSpell lost target somewhere!", LIGHT_RED);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
@@ -2813,6 +2826,7 @@ void GameScript::ForceSpell(Scriptable* Sender, Action* parameters)
|
||||
//stop doing anything else
|
||||
act->SetModal(MS_NONE);
|
||||
}
|
||||
Sender->CurrentActionState = 1;
|
||||
int duration = Sender->CastSpell (spellres, tar, false);
|
||||
if (duration != -1) Sender->SetWait(duration);
|
||||
|
||||
@@ -2838,9 +2852,13 @@ void GameScript::ForceSpellPoint(Scriptable* Sender, Action* parameters)
|
||||
}
|
||||
}
|
||||
|
||||
//if target was set, fire spell
|
||||
if (!Sender->LastTargetPos.isempty()) {
|
||||
Sender->CastSpellPointEnd(0);
|
||||
if (Sender->CurrentActionState) {
|
||||
if(!Sender->LastTargetPos.isempty()) {
|
||||
//if target was set, fire spell
|
||||
Sender->CastSpellPointEnd(0);
|
||||
} else {
|
||||
printMessage("GameScript", "ForceSpellPoint lost target somewhere!", LIGHT_RED);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
@@ -2854,6 +2872,7 @@ void GameScript::ForceSpellPoint(Scriptable* Sender, Action* parameters)
|
||||
act->SetModal(MS_NONE);
|
||||
}
|
||||
|
||||
Sender->CurrentActionState = 1;
|
||||
int duration = Sender->CastSpellPoint (spellres, parameters->pointParameter, false);
|
||||
if (duration != -1) Sender->SetWait(duration);
|
||||
|
||||
@@ -2975,9 +2994,9 @@ void GameScript::ReallyForceSpellDead(Scriptable* Sender, Action* parameters)
|
||||
level = parameters->int1Parameter;
|
||||
}
|
||||
if (tar->Type==ST_ACTOR) {
|
||||
Sender->CastSpellEnd(parameters->int1Parameter);
|
||||
Sender->CastSpellEnd(level);
|
||||
} else {
|
||||
Sender->CastSpellPointEnd(parameters->int1Parameter);
|
||||
Sender->CastSpellPointEnd(level);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
}
|
||||
@@ -3387,18 +3406,18 @@ void GameScript::PlayDead(Scriptable* Sender, Action* parameters)
|
||||
return;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
|
||||
actor->CurrentActionInterruptable = false;
|
||||
if (Sender->CurrentActionState == 0) {
|
||||
// TODO: what if parameter is 0? see orphan2
|
||||
if (!Sender->CurrentActionTicks && parameters->int0Parameter) {
|
||||
// set countdown on first run
|
||||
Sender->CurrentActionState = parameters->int0Parameter;
|
||||
actor->SetStance( IE_ANI_DIE );
|
||||
} else {
|
||||
actor->CurrentActionState--;
|
||||
if (Sender->CurrentActionState == 0) {
|
||||
actor->SetStance( IE_ANI_GET_UP );
|
||||
Sender->ReleaseCurrentAction();
|
||||
}
|
||||
}
|
||||
if (Sender->CurrentActionState <= 0) {
|
||||
actor->SetStance( IE_ANI_GET_UP );
|
||||
Sender->ReleaseCurrentAction();
|
||||
}
|
||||
actor->CurrentActionState--;
|
||||
}
|
||||
|
||||
void GameScript::PlayDeadInterruptable(Scriptable* Sender, Action* parameters)
|
||||
@@ -3408,17 +3427,17 @@ void GameScript::PlayDeadInterruptable(Scriptable* Sender, Action* parameters)
|
||||
return;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
if (Sender->CurrentActionState == 0) {
|
||||
// TODO: what if parameter is 0? see orphan2
|
||||
|
||||
if (!Sender->CurrentActionTicks && parameters->int0Parameter) {
|
||||
// set countdown on first run
|
||||
Sender->CurrentActionState = parameters->int0Parameter;
|
||||
actor->SetStance( IE_ANI_DIE );
|
||||
} else {
|
||||
actor->CurrentActionState--;
|
||||
if (Sender->CurrentActionState == 0) {
|
||||
actor->SetStance( IE_ANI_GET_UP );
|
||||
Sender->ReleaseCurrentAction();
|
||||
}
|
||||
}
|
||||
if (Sender->CurrentActionState <= 0) {
|
||||
actor->SetStance( IE_ANI_GET_UP );
|
||||
Sender->ReleaseCurrentAction();
|
||||
}
|
||||
actor->CurrentActionState--;
|
||||
}
|
||||
|
||||
/* this may not be correct, just a placeholder you can fix */
|
||||
@@ -3863,7 +3882,7 @@ void GameScript::MakeUnselectable(Scriptable* Sender, Action* parameters)
|
||||
void GameScript::Debug(Scriptable* /*Sender*/, Action* parameters)
|
||||
{
|
||||
InDebug=parameters->int0Parameter;
|
||||
printMessage("GameScript",parameters->string0Parameter,YELLOW);
|
||||
printMessage("GameScript","%s",YELLOW,parameters->string0Parameter);
|
||||
}
|
||||
|
||||
void GameScript::IncrementProficiency(Scriptable* Sender, Action* parameters)
|
||||
@@ -4269,7 +4288,10 @@ void GameScript::CreateItem(Scriptable *Sender, Action* parameters)
|
||||
}
|
||||
|
||||
CREItem *item = new CREItem();
|
||||
CreateItemCore(item, parameters->string0Parameter, parameters->int0Parameter, parameters->int1Parameter, parameters->int2Parameter);
|
||||
if (!CreateItemCore(item, parameters->string0Parameter, parameters->int0Parameter, parameters->int1Parameter, parameters->int2Parameter)) {
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
if (tar->Type==ST_CONTAINER) {
|
||||
myinv->AddItem(item);
|
||||
} else {
|
||||
@@ -4300,7 +4322,10 @@ void GameScript::CreateItemNumGlobal(Scriptable *Sender, Action* parameters)
|
||||
}
|
||||
int value = CheckVariable( Sender, parameters->string0Parameter );
|
||||
CREItem *item = new CREItem();
|
||||
CreateItemCore(item, parameters->string1Parameter, value, 0, 0);
|
||||
if (!CreateItemCore(item, parameters->string1Parameter, value, 0, 0)) {
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
if (Sender->Type==ST_CONTAINER) {
|
||||
myinv->AddItem(item);
|
||||
} else {
|
||||
@@ -4328,7 +4353,10 @@ void GameScript::TakeItemReplace(Scriptable *Sender, Action* parameters)
|
||||
if (!item) {
|
||||
item = new CREItem();
|
||||
}
|
||||
CreateItemCore(item, parameters->string0Parameter, -1, 0, 0);
|
||||
if (!CreateItemCore(item, parameters->string0Parameter, -1, 0, 0)) {
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
if (ASI_SUCCESS != scr->inventory.AddSlotItem(item,slot)) {
|
||||
Map *map = scr->GetCurrentArea();
|
||||
map->AddItemToLocation(Sender->Pos, item);
|
||||
@@ -4600,10 +4628,11 @@ void GameScript::PickPockets(Scriptable *Sender, Action* parameters)
|
||||
//noticed attempt
|
||||
displaymsg->DisplayConstantString(STR_PICKPOCKET_FAIL,0xffffff);
|
||||
if (core->HasFeature(GF_STEAL_IS_ATTACK) ) {
|
||||
tar->LastAttacker = snd->GetGlobalID();
|
||||
tar->AddTrigger(TriggerEntry(trigger_attackedby, snd->GetGlobalID()));
|
||||
tar->LastAttacker = snd->GetGlobalID(); // FIXME
|
||||
} else {
|
||||
//pickpocket failed trigger
|
||||
tar->LastOpenFailed = snd->GetGlobalID();
|
||||
tar->AddTrigger(TriggerEntry(trigger_pickpocketfailed, snd->GetGlobalID()));
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
@@ -4635,7 +4664,9 @@ void GameScript::PickPockets(Scriptable *Sender, Action* parameters)
|
||||
return;
|
||||
}
|
||||
CREItem *item = new CREItem();
|
||||
CreateItemCore(item, core->GoldResRef, money, 0, 0);
|
||||
if (!CreateItemCore(item, core->GoldResRef, money, 0, 0)) {
|
||||
abort();
|
||||
}
|
||||
if ( ASI_SUCCESS == snd->inventory.AddSlotItem(item, SLOT_ONLYINVENTORY)) {
|
||||
scr->SetBase(IE_GOLD,scr->GetBase(IE_GOLD)-money);
|
||||
} else {
|
||||
@@ -4763,6 +4794,16 @@ void GameScript::QuitGame(Scriptable* Sender, Action* parameters)
|
||||
core->SetNextScript("QuitGame");
|
||||
}
|
||||
|
||||
//BG2 demo end, shows some pictures then goes to main screen
|
||||
void GameScript::DemoEnd(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
ClearAllActions(Sender, parameters);
|
||||
core->GetDictionary()->SetAt("QuitGame1", (ieDword)0);
|
||||
core->GetDictionary()->SetAt("QuitGame2", (ieDword)0);
|
||||
core->GetDictionary()->SetAt("QuitGame3", (ieDword)-1);
|
||||
core->SetNextScript("QuitGame");
|
||||
}
|
||||
|
||||
void GameScript::StopMoving(Scriptable* Sender, Action* /*parameters*/)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
@@ -4886,8 +4927,7 @@ void GameScript::RevealAreaOnMap(Scriptable* /*Sender*/, Action* parameters)
|
||||
{
|
||||
WorldMap *worldmap = core->GetWorldMap();
|
||||
if (!worldmap) {
|
||||
printf("Can't find worldmap!\n");
|
||||
abort();
|
||||
error("GameScript", "Can't find worldmap!\n");
|
||||
}
|
||||
// WMP_ENTRY_ADJACENT because otherwise revealed bg2 areas are unreachable from city gates
|
||||
worldmap->SetAreaStatus(parameters->string0Parameter, WMP_ENTRY_VISIBLE|WMP_ENTRY_ADJACENT, BM_OR);
|
||||
@@ -4898,8 +4938,7 @@ void GameScript::HideAreaOnMap( Scriptable* /*Sender*/, Action* parameters)
|
||||
{
|
||||
WorldMap *worldmap = core->GetWorldMap();
|
||||
if (!worldmap) {
|
||||
printf("Can't find worldmap!\n");
|
||||
abort();
|
||||
error("GameScript", "Can't find worldmap!\n");
|
||||
}
|
||||
// WMP_ENTRY_ADJACENT because otherwise revealed bg2 areas are unreachable from city gates
|
||||
worldmap->SetAreaStatus(parameters->string0Parameter, WMP_ENTRY_VISIBLE|WMP_ENTRY_ADJACENT, BM_NAND);
|
||||
@@ -4911,7 +4950,7 @@ void GameScript::SendTrigger(Scriptable* Sender, Action* parameters)
|
||||
if (!tar) {
|
||||
return;
|
||||
}
|
||||
tar->TriggerID=parameters->int0Parameter;
|
||||
tar->AddTrigger(TriggerEntry(trigger_trigger, parameters->int0Parameter));
|
||||
}
|
||||
|
||||
void GameScript::Shout( Scriptable* Sender, Action* parameters)
|
||||
@@ -4957,8 +4996,7 @@ void GameScript::GiveOrder(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
Scriptable* tar = GetActorFromObject( Sender, parameters->objects[1] );
|
||||
if (tar) {
|
||||
tar->LastOrderer = Sender->GetGlobalID();
|
||||
tar->LastOrder = parameters->int0Parameter;
|
||||
tar->AddTrigger(TriggerEntry(trigger_receivedorder, Sender->GetGlobalID(), parameters->int0Parameter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5865,7 +5903,7 @@ void GameScript::SaveGame(Scriptable* /*Sender*/, Action* parameters)
|
||||
void GameScript::EscapeArea(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
if (InDebug&ID_ACTIONS) {
|
||||
printf("EscapeArea/EscapeAreaMove\n");
|
||||
print("EscapeArea/EscapeAreaMove\n");
|
||||
}
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
Sender->ReleaseCurrentAction();
|
||||
@@ -5893,7 +5931,7 @@ void GameScript::EscapeArea(Scriptable* Sender, Action* parameters)
|
||||
void GameScript::EscapeAreaNoSee(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
if (InDebug&ID_ACTIONS) {
|
||||
printf("EscapeAreaNoSee\n");
|
||||
print("EscapeAreaNoSee\n");
|
||||
}
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
Sender->ReleaseCurrentAction();
|
||||
@@ -6224,12 +6262,13 @@ void GameScript::SetNoOneOnTrigger(Scriptable* Sender, Action* parameters)
|
||||
ip = Sender->GetCurrentArea()->TMap->GetInfoPoint(parameters->objects[1]->objectName);
|
||||
}
|
||||
if (!ip || (ip->Type!=ST_TRIGGER && ip->Type!=ST_TRAVEL && ip->Type!=ST_PROXIMITY)) {
|
||||
printf("Script error: No Trigger Named \"%s\"\n", parameters->objects[1]->objectName);
|
||||
print("Script error: No Trigger Named \"%s\"\n", parameters->objects[1]->objectName);
|
||||
return;
|
||||
}
|
||||
ip->LastEntered = 0;
|
||||
// FIXME: what does this do? clear triggers?
|
||||
/*ip->LastEntered = 0;
|
||||
ip->LastTrigger = 0;
|
||||
ip->LastTriggerObject = 0;
|
||||
ip->LastTriggerObject = 0;*/
|
||||
}
|
||||
|
||||
void GameScript::UseDoor(Scriptable* Sender, Action* parameters)
|
||||
@@ -6348,7 +6387,8 @@ void GameScript::ChangeDestination(Scriptable* Sender, Action* parameters)
|
||||
{
|
||||
InfoPoint *ip = Sender->GetCurrentArea()->TMap->GetInfoPoint(parameters->objects[1]->objectName);
|
||||
if (ip && (ip->Type==ST_TRAVEL) ) {
|
||||
strnlwrcpy(ip->Destination, parameters->string0Parameter, 32);
|
||||
//alter the destination area, don't touch the entrance variable link
|
||||
strnlwrcpy(ip->Destination, parameters->string0Parameter, sizeof(ieResRef)-1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6794,7 +6834,8 @@ void GameScript::ProtectObject(Scriptable* Sender, Action* parameters)
|
||||
Actor *scr = (Actor *)Sender;
|
||||
Actor *actor = (Actor *)tar;
|
||||
scr->LastFollowed = actor->GetGlobalID();
|
||||
scr->LastProtected = actor->GetGlobalID();
|
||||
scr->LastProtectee = actor->GetGlobalID();
|
||||
actor->LastProtector = scr->GetGlobalID();
|
||||
//not exactly range
|
||||
scr->FollowOffset.x = parameters->int0Parameter;
|
||||
scr->FollowOffset.y = parameters->int0Parameter;
|
||||
@@ -7148,7 +7189,7 @@ void GameScript::SetToken2DA(Scriptable* /*Sender*/, Action* parameters)
|
||||
AutoTable tm(parameters->string0Parameter);
|
||||
if (!tm) {
|
||||
printStatus( "ERROR", LIGHT_RED );
|
||||
printf( "Cannot find %s.2da.\n", parameters->string0Parameter);
|
||||
print( "Cannot find %s.2da.\n", parameters->string0Parameter);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,15 +25,18 @@
|
||||
#include "defsounds.h"
|
||||
|
||||
#include "Audio.h"
|
||||
#include "CharAnimations.h"
|
||||
#include "DialogHandler.h"
|
||||
#include "DisplayMessage.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "Interface.h"
|
||||
#include "Item.h"
|
||||
#include "Map.h"
|
||||
#include "Spell.h"
|
||||
#include "StringMgr.h"
|
||||
#include "TableMgr.h"
|
||||
#include "TileMap.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/GameControl.h"
|
||||
@@ -239,24 +242,9 @@ bool ResolveItemName(ieResRef itemres, Actor *act, ieDword Slot)
|
||||
|
||||
bool StoreHasItemCore(const ieResRef storename, const ieResRef itemname)
|
||||
{
|
||||
bool had_nostore=false;
|
||||
bool has_current=false;
|
||||
ieResRef current;
|
||||
ieDword owner = 0;
|
||||
CREItem item;
|
||||
|
||||
Store *store = core->GetCurrentStore();
|
||||
if (!store) {
|
||||
had_nostore = true;
|
||||
store = core->SetCurrentStore(storename, 0);
|
||||
} else {
|
||||
if (strnicmp(store->Name, storename, 8) ) {
|
||||
//not the current store, we need some dirty hack
|
||||
has_current = true;
|
||||
strnlwrcpy(current, store->Name, 8);
|
||||
owner = store->GetOwnerID();
|
||||
}
|
||||
}
|
||||
Store* store = gamedata->GetStore(storename);
|
||||
if (!store) {
|
||||
printMessage("GameScript","Store cannot be opened!\n", LIGHT_RED);
|
||||
return false;
|
||||
@@ -267,12 +255,7 @@ bool StoreHasItemCore(const ieResRef storename, const ieResRef itemname)
|
||||
if (store->FindItem(itemname, false) != (unsigned int)-1) {
|
||||
ret=true;
|
||||
}
|
||||
if (has_current) {
|
||||
//setting back old store (this will save our current store)
|
||||
core->SetCurrentStore(current, owner);
|
||||
} else if (had_nostore) {
|
||||
core->CloseCurrentStore();
|
||||
}
|
||||
// Don't call gamedata->SaveStore, we don't change it, and it remains cached.
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -368,7 +351,7 @@ void DisplayStringCore(Scriptable* Sender, int Strref, int flags)
|
||||
|
||||
memset(&sb,0,sizeof(sb));
|
||||
Sound[0]=0;
|
||||
printf( "Displaying string on: %s\n", Sender->GetScriptName() );
|
||||
print( "Displaying string on: %s\n", Sender->GetScriptName() );
|
||||
if (flags & DS_CONST) {
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
printMessage("GameScript","Verbal constant not supported for non actors!\n", LIGHT_RED);
|
||||
@@ -599,8 +582,8 @@ void CreateCreatureCore(Scriptable* Sender, Action* parameters, int flags)
|
||||
}
|
||||
|
||||
if (!ab) {
|
||||
printMessage("GameScript","Failed to create creature! ",LIGHT_RED);
|
||||
printf("(missing creature file %s?)\n", parameters->string0Parameter);
|
||||
printMessage("GameScript", "Failed to create creature! (missing creature file %s?)\n", LIGHT_RED,
|
||||
parameters->string0Parameter);
|
||||
// maybe this should abort()?
|
||||
return;
|
||||
}
|
||||
@@ -725,7 +708,7 @@ void EscapeAreaCore(Scriptable* Sender, const Point &p, const char* area, const
|
||||
//MoveNearerTo will return 0, if the actor is in move
|
||||
//it will return 1 (the fourth parameter) if the target is unreachable
|
||||
if (!MoveNearerTo(Sender, p, MAX_OPERATING_DISTANCE,1) ) {
|
||||
if (!Sender->InMove()) printf("At least it said so...\n");
|
||||
if (!Sender->InMove()) print("At least it said so...\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -737,13 +720,12 @@ void EscapeAreaCore(Scriptable* Sender, const Point &p, const char* area, const
|
||||
// last parameter is 'face', which should be passed from relevant action parameter..
|
||||
sprintf( Tmp, "MoveBetweenAreas(\"%s\",[%hd.%hd],%d)", area, enter.x, enter.y, 0 );
|
||||
}
|
||||
printMessage("GSUtils"," ", WHITE);
|
||||
printf("Executing %s in EscapeAreaCore\n", Tmp);
|
||||
printMessage("GSUtils", "Executing %s in EscapeAreaCore\n", WHITE, Tmp);
|
||||
//drop this action, but add another (destroyself or movebetweenareas)
|
||||
//between the arrival and the final escape, there should be a wait time
|
||||
//that wait time could be handled here
|
||||
if (wait) {
|
||||
printf("But wait a bit... (%d)\n", wait);
|
||||
print("But wait a bit... (%d)\n", wait);
|
||||
Sender->SetWait(wait);
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
@@ -825,7 +807,7 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags)
|
||||
int seeflag = GA_NO_DEAD;
|
||||
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("BeginDialog core\n");
|
||||
print("BeginDialog core\n");
|
||||
}
|
||||
if (Flags & BD_OWN) {
|
||||
tar = GetStoredActorFromObject( Sender, parameters->objects[1], seeflag);
|
||||
@@ -835,23 +817,23 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags)
|
||||
scr = Sender;
|
||||
}
|
||||
if (!scr) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Speaker for dialog couldn't be found (Sender: %s, Type: %d) Flags:%d.\n", Sender->GetScriptName(), Sender->Type, Flags);
|
||||
printMessage("GameScript", "Speaker for dialog couldn't be found (Sender: %s, Type: %d) Flags:%d.\n", LIGHT_RED,
|
||||
Sender->GetScriptName(), Sender->Type, Flags);
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tar || tar->Type!=ST_ACTOR) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Target for dialog couldn't be found (Sender: %s, Type: %d).\n", Sender->GetScriptName(), Sender->Type);
|
||||
printMessage("GameScript", "Target for dialog couldn't be found (Sender: %s, Type: %d).\n", LIGHT_RED,
|
||||
Sender->GetScriptName(), Sender->Type);
|
||||
if (Sender->Type == ST_ACTOR) {
|
||||
((Actor *) Sender)->DebugDump();
|
||||
}
|
||||
printf ("Target object: ");
|
||||
print ("Target object: ");
|
||||
if (parameters->objects[1]) {
|
||||
parameters->objects[1]->Dump();
|
||||
} else {
|
||||
printf("<NULL>\n");
|
||||
print("<NULL>\n");
|
||||
}
|
||||
Sender->ReleaseCurrentAction();
|
||||
return;
|
||||
@@ -862,8 +844,8 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags)
|
||||
speaker = NULL;
|
||||
target = (Actor *) tar;
|
||||
if ((Flags & BD_CHECKDIST) && !CanSee(scr, target, false, seeflag) ) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("CanSee returned false! Speaker (%s, type %d) and target are:\n", scr->GetScriptName(), scr->Type);
|
||||
printMessage("GameScript", "CanSee returned false! Speaker (%s, type %d) and target are:\n", LIGHT_RED,
|
||||
scr->GetScriptName(), scr->Type);
|
||||
if (scr->Type == ST_ACTOR) {
|
||||
((Actor *) scr)->DebugDump();
|
||||
}
|
||||
@@ -876,7 +858,7 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags)
|
||||
speaker = (Actor *) scr;
|
||||
if (speaker->GetStat(IE_STATE_ID)&STATE_DEAD) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Speaker is dead, cannot start dialogue. Speaker and target are:\n");
|
||||
print("Speaker is dead, cannot start dialogue. Speaker and target are:\n");
|
||||
speaker->DebugDump();
|
||||
target->DebugDump();
|
||||
Sender->ReleaseCurrentAction();
|
||||
@@ -1032,7 +1014,7 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags)
|
||||
}
|
||||
}
|
||||
|
||||
int ret;
|
||||
bool ret;
|
||||
|
||||
if (Dialog[0]) {
|
||||
//increasing NumTimesTalkedTo or NumTimesInteracted
|
||||
@@ -1046,28 +1028,24 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags)
|
||||
ret = gc->dialoghandler->InitDialog( scr, tar, Dialog);
|
||||
}
|
||||
else {
|
||||
ret = -1;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if (ret<0) {
|
||||
Sender->ReleaseCurrentAction();
|
||||
Sender->ReleaseCurrentAction();
|
||||
|
||||
if (!ret) {
|
||||
if (Flags & BD_NOEMPTY) {
|
||||
return;
|
||||
}
|
||||
displaymsg->DisplayConstantStringName(STR_NOTHINGTOSAY,0xff0000,tar);
|
||||
return;
|
||||
}
|
||||
|
||||
//this is a bit fishy
|
||||
Sender->SetWait(1);
|
||||
Sender->ReleaseCurrentAction();
|
||||
|
||||
}
|
||||
|
||||
void MoveBetweenAreasCore(Actor* actor, const char *area, const Point &position, int face, bool adjust)
|
||||
{
|
||||
printMessage("GameScript", " ", WHITE);
|
||||
printf("MoveBetweenAreas: %s to %s [%d.%d] face: %d\n", actor->GetName(0), area,position.x,position.y, face);
|
||||
printMessage("GameScript", "MoveBetweenAreas: %s to %s [%d.%d] face: %d\n", WHITE,
|
||||
actor->GetName(0), area,position.x,position.y, face);
|
||||
Map* map2;
|
||||
Game* game = core->GetGame();
|
||||
if (area[0]) { //do we need to switch area?
|
||||
@@ -1139,11 +1117,12 @@ void MoveToObjectCore(Scriptable *Sender, Action *parameters, ieDword flags, boo
|
||||
Sender->ReleaseCurrentAction();
|
||||
}
|
||||
|
||||
void CreateItemCore(CREItem *item, const char *resref, int a, int b, int c)
|
||||
bool CreateItemCore(CREItem *item, const char *resref, int a, int b, int c)
|
||||
{
|
||||
//copy the whole resref, including the terminating zero
|
||||
strnuprcpy(item->ItemResRef, resref, 8);
|
||||
core->ResolveRandomItem(item);
|
||||
if (!core->ResolveRandomItem(item))
|
||||
return false;
|
||||
if (a==-1) {
|
||||
//use the default charge counts of the item
|
||||
Item *origitem = gamedata->GetItem(item->ItemResRef);
|
||||
@@ -1160,6 +1139,7 @@ void CreateItemCore(CREItem *item, const char *resref, int a, int b, int c)
|
||||
item->Usages[2]=(ieWord) c;
|
||||
}
|
||||
item->Flags=0;
|
||||
return true;
|
||||
}
|
||||
|
||||
//It is possible to attack CONTAINERS/DOORS as well!!!
|
||||
@@ -1264,8 +1244,8 @@ static int GetIdsValue(const char *&symbol, const char *idsname)
|
||||
if (!valHook) {
|
||||
//FIXME:missing ids file!!!
|
||||
if (InDebug&ID_TRIGGERS) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Missing IDS file %s for symbol %s!\n",idsname, symbol);
|
||||
printMessage("GameScript", "Missing IDS file %s for symbol %s!\n", LIGHT_RED,
|
||||
idsname, symbol);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -1363,11 +1343,11 @@ Action* GenerateActionCore(const char *src, const char *str, unsigned short acti
|
||||
//Here is the Action; Now we need to evaluate the parameters, if any
|
||||
if (*str!=')') while (*str) {
|
||||
if (*(str+1)!=':') {
|
||||
printf("Warning, parser was sidetracked: %s\n",str);
|
||||
print("Warning, parser was sidetracked: %s\n",str);
|
||||
}
|
||||
switch (*str) {
|
||||
default:
|
||||
printf("Invalid type: %s\n",str);
|
||||
print("Invalid type: %s\n",str);
|
||||
//str++;
|
||||
delete newAction;
|
||||
return NULL;
|
||||
@@ -1460,7 +1440,7 @@ Action* GenerateActionCore(const char *src, const char *str, unsigned short acti
|
||||
|
||||
case 'o': //Object
|
||||
if (objectCount==3) {
|
||||
printf("Invalid object count!\n");
|
||||
print("Invalid object count!\n");
|
||||
//abort();
|
||||
delete newAction;
|
||||
return NULL;
|
||||
@@ -1514,7 +1494,7 @@ Action* GenerateActionCore(const char *src, const char *str, unsigned short acti
|
||||
if (mergestrings) {
|
||||
str++;
|
||||
if (*str!='s') {
|
||||
printf("Invalid mergestrings:%s\n",str);
|
||||
print("Invalid mergestrings:%s\n",str);
|
||||
//abort();
|
||||
delete newAction;
|
||||
return NULL;
|
||||
@@ -1644,9 +1624,7 @@ void FreeSrc(SrcVector *poi, const ieResRef key)
|
||||
{
|
||||
int res = SrcCache.DecRef((void *) poi, key, true);
|
||||
if (res<0) {
|
||||
printMessage( "GameScript", "Corrupted Src cache encountered (reference count went below zero), ", LIGHT_RED );
|
||||
printf( "Src name is: %.8s\n", key);
|
||||
abort();
|
||||
error("GameScript", "Corrupted Src cache encountered (reference count went below zero), Src name is: %.8s\n", key);
|
||||
}
|
||||
if (!res) {
|
||||
delete poi;
|
||||
@@ -1733,11 +1711,11 @@ Trigger *GenerateTriggerCore(const char *src, const char *str, int trIndex, int
|
||||
//Here is the Trigger; Now we need to evaluate the parameters
|
||||
if (*str!=')') while (*str) {
|
||||
if (*(str+1)!=':') {
|
||||
printf("Warning, parser was sidetracked: %s\n",str);
|
||||
print("Warning, parser was sidetracked: %s\n",str);
|
||||
}
|
||||
switch (*str) {
|
||||
default:
|
||||
printf("Invalid type: %s\n",str);
|
||||
print("Invalid type: %s\n",str);
|
||||
//str++;
|
||||
delete newTrigger;
|
||||
return NULL;
|
||||
@@ -1833,7 +1811,7 @@ Trigger *GenerateTriggerCore(const char *src, const char *str, int trIndex, int
|
||||
if (mergestrings) {
|
||||
str++;
|
||||
if (*str!='s') {
|
||||
printf("Invalid mergestrings:%s\n",str);
|
||||
print("Invalid mergestrings:%s\n",str);
|
||||
//abort();
|
||||
delete newTrigger;
|
||||
return NULL;
|
||||
@@ -1880,7 +1858,7 @@ void SetVariable(Scriptable* Sender, const char* VarName, const char* Context, i
|
||||
char newVarName[8+33];
|
||||
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf( "Setting variable(\"%s%s\", %d)\n", Context,
|
||||
print( "Setting variable(\"%s%s\", %d)\n", Context,
|
||||
VarName, value );
|
||||
}
|
||||
|
||||
@@ -1906,8 +1884,8 @@ void SetVariable(Scriptable* Sender, const char* VarName, const char* Context, i
|
||||
map->locals->SetAt( VarName, value, NoCreate);
|
||||
}
|
||||
else if (InDebug&ID_VARIABLES) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Invalid variable %s %s in setvariable\n",Context, VarName);
|
||||
printMessage("GameScript", "Invalid variable %s %s in setvariable\n", YELLOW,
|
||||
Context, VarName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1927,7 +1905,7 @@ void SetVariable(Scriptable* Sender, const char* VarName, ieDword value)
|
||||
}
|
||||
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf( "Setting variable(\"%s\", %d)\n", VarName, value );
|
||||
print( "Setting variable(\"%s\", %d)\n", VarName, value );
|
||||
}
|
||||
strncpy( newVarName, VarName, 6 );
|
||||
newVarName[6]=0;
|
||||
@@ -1950,8 +1928,8 @@ void SetVariable(Scriptable* Sender, const char* VarName, ieDword value)
|
||||
map->locals->SetAt( poi, value, NoCreate);
|
||||
}
|
||||
else if (InDebug&ID_VARIABLES) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Invalid variable %s in setvariable\n",VarName);
|
||||
printMessage("GameScript", "Invalid variable %s in setvariable\n", YELLOW,
|
||||
VarName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1976,14 +1954,14 @@ ieDword CheckVariable(Scriptable* Sender, const char* VarName, bool *valid)
|
||||
if (strnicmp( newVarName, "MYAREA", 6 ) == 0) {
|
||||
Sender->GetCurrentArea()->locals->Lookup( poi, value );
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s: %d\n",VarName, value);
|
||||
print("CheckVariable %s: %d\n",VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if (strnicmp( newVarName, "LOCALS", 6 ) == 0) {
|
||||
Sender->locals->Lookup( poi, value );
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s: %d\n",VarName, value);
|
||||
print("CheckVariable %s: %d\n",VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -1991,7 +1969,7 @@ ieDword CheckVariable(Scriptable* Sender, const char* VarName, bool *valid)
|
||||
if (HasKaputz && !strnicmp(newVarName,"KAPUTZ",6) ) {
|
||||
game->kaputz->Lookup( poi, value );
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s: %d\n",VarName, value);
|
||||
print("CheckVariable %s: %d\n",VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -2004,15 +1982,15 @@ ieDword CheckVariable(Scriptable* Sender, const char* VarName, bool *valid)
|
||||
*valid=false;
|
||||
}
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Invalid variable %s in checkvariable\n",VarName);
|
||||
printMessage("GameScript", "Invalid variable %s in checkvariable\n", YELLOW,
|
||||
VarName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
game->locals->Lookup( poi, value );
|
||||
}
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s: %d\n",VarName, value);
|
||||
print("CheckVariable %s: %d\n",VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -2027,14 +2005,14 @@ ieDword CheckVariable(Scriptable* Sender, const char* VarName, const char* Conte
|
||||
if (strnicmp( newVarName, "MYAREA", 6 ) == 0) {
|
||||
Sender->GetCurrentArea()->locals->Lookup( VarName, value );
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
print("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if (strnicmp( newVarName, "LOCALS", 6 ) == 0) {
|
||||
Sender->locals->Lookup( VarName, value );
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
print("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -2042,7 +2020,7 @@ ieDword CheckVariable(Scriptable* Sender, const char* VarName, const char* Conte
|
||||
if (HasKaputz && !strnicmp(newVarName,"KAPUTZ",6) ) {
|
||||
game->kaputz->Lookup( VarName, value );
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
print("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -2055,15 +2033,15 @@ ieDword CheckVariable(Scriptable* Sender, const char* VarName, const char* Conte
|
||||
*valid=false;
|
||||
}
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Invalid variable %s %s in checkvariable\n",Context, VarName);
|
||||
printMessage("GameScript", "Invalid variable %s %s in checkvariable\n", YELLOW,
|
||||
Context, VarName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
game->locals->Lookup( VarName, value );
|
||||
}
|
||||
if (InDebug&ID_VARIABLES) {
|
||||
printf("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
print("CheckVariable %s%s: %d\n",Context, VarName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -2172,8 +2150,7 @@ unsigned int GetSpellDistance(const ieResRef spellres, Scriptable *Sender)
|
||||
|
||||
Spell* spl = gamedata->GetSpell( spellres );
|
||||
if (!spl) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Spell couldn't be found:%.8s.\n", spellres);
|
||||
printMessage("GameScript", "Spell couldn't be found:%.8s.\n", LIGHT_RED, spellres);
|
||||
return 0;
|
||||
}
|
||||
dist = spl->GetCastingDistance(Sender);
|
||||
@@ -2195,8 +2172,7 @@ unsigned int GetItemDistance(const ieResRef itemres, int header)
|
||||
|
||||
Item* itm = gamedata->GetItem( itemres );
|
||||
if (!itm) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Item couldn't be found:%.8s.\n", itemres);
|
||||
printMessage("GameScript", "Item couldn't be found:%.8s.\n", LIGHT_RED, itemres);
|
||||
return 0;
|
||||
}
|
||||
dist=itm->GetCastingDistance(header);
|
||||
@@ -2224,7 +2200,7 @@ void SetupWishCore(Scriptable *Sender, int column, int picks)
|
||||
AutoTable tm("wish");
|
||||
if (!tm) {
|
||||
printStatus( "ERROR", LIGHT_RED );
|
||||
printf( "Cannot find wish.2da.\n");
|
||||
print( "Cannot find wish.2da.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ void PolymorphCopyCore(Actor *src, Actor *tar, bool base);
|
||||
void CreateCreatureCore(Scriptable* Sender, Action* parameters, int flags);
|
||||
int MoveItemCore(Scriptable *Sender, Scriptable *target, const char *resref, int flags, int setflag);
|
||||
void MoveToObjectCore(Scriptable *Sender, Action *parameters, ieDword flags, bool untilsee);
|
||||
void CreateItemCore(CREItem *item, const char *resref, int a, int b, int c);
|
||||
bool CreateItemCore(CREItem *item, const char *resref, int a, int b, int c);
|
||||
void AttackCore(Scriptable *Sender, Scriptable *target, int flags);
|
||||
void InitScriptTables();
|
||||
void HandleBitMod(ieDword &value1, ieDword value2, int opcode);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "GameData.h"
|
||||
#include "Interface.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "TableMgr.h"
|
||||
|
||||
//debug flags
|
||||
// 1 - cache
|
||||
@@ -225,6 +226,7 @@ static const TriggerLink triggernames[] = {
|
||||
{"isweather", GameScript::IsWeather, 0}, //gemrb extension
|
||||
{"itemisidentified", GameScript::ItemIsIdentified, 0},
|
||||
{"joins", GameScript::Joins, 0},
|
||||
{"killed", GameScript::Killed, 0},
|
||||
{"kit", GameScript::Kit, 0},
|
||||
{"knowspell", GameScript::KnowSpell, 0}, //gemrb specific
|
||||
{"lastmarkedobject", GameScript::LastMarkedObject_Trigger, 0},
|
||||
@@ -506,7 +508,7 @@ static const ActionLink actionnames[] = {
|
||||
{"debug", GameScript::Debug, 0},
|
||||
{"debugoutput", GameScript::Debug, 0},
|
||||
{"deletejournalentry", GameScript::RemoveJournalEntry, 0},
|
||||
{"demoend", GameScript::QuitGame, 0}, //same for now
|
||||
{"demoend", GameScript::DemoEnd, 0}, //same for now
|
||||
{"destroyalldestructableequipment", GameScript::DestroyAllDestructableEquipment, 0},
|
||||
{"destroyallequipment", GameScript::DestroyAllEquipment, 0},
|
||||
{"destroygold", GameScript::DestroyGold, 0},
|
||||
@@ -1133,8 +1135,8 @@ static const IDSLink* FindIdentifier(const char* idsname)
|
||||
}
|
||||
}
|
||||
|
||||
printMessage( "GameScript"," ", YELLOW );
|
||||
printf( "Couldn't assign ids target: %.*s\n", len, idsname );
|
||||
printMessage("GameScript", "Couldn't assign ids target: %.*s\n", YELLOW,
|
||||
len, idsname );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1271,9 +1273,9 @@ void printFunction(Holder<SymbolMgr> table, int index)
|
||||
|
||||
int len = strchr(str,'(')-str;
|
||||
if (len<0) {
|
||||
printf("%d %s\n", value, str);
|
||||
print("%d %s\n", value, str);
|
||||
} else {
|
||||
printf("%d %.*s\n", value, len, str);
|
||||
print("%d %.*s\n", value, len, str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1296,16 +1298,14 @@ void InitializeIEScript()
|
||||
int gaT = core->LoadSymbol( "gemact" );
|
||||
AutoTable objNameTable("script");
|
||||
if (tT < 0 || aT < 0 || oT < 0 || !objNameTable) {
|
||||
printMessage( "GameScript","A critical scripting file is missing!\n",LIGHT_RED );
|
||||
abort();
|
||||
error("GameScript", "A critical scripting file is missing!\n");
|
||||
}
|
||||
triggersTable = core->GetSymbol( tT );
|
||||
actionsTable = core->GetSymbol( aT );
|
||||
objectsTable = core->GetSymbol( oT );
|
||||
overrideActionsTable = core->GetSymbol( gaT );
|
||||
if (!triggersTable || !actionsTable || !objectsTable || !objNameTable) {
|
||||
printMessage( "GameScript","A critical scripting file is damaged!\n",LIGHT_RED );
|
||||
abort();
|
||||
error("GameScript", "A critical scripting file is damaged!\n");
|
||||
}
|
||||
|
||||
int i;
|
||||
@@ -1314,8 +1314,7 @@ void InitializeIEScript()
|
||||
|
||||
ObjectIDSCount = atoi( objNameTable->QueryField() );
|
||||
if (ObjectIDSCount<0 || ObjectIDSCount>MAX_OBJECT_FIELDS) {
|
||||
printMessage("GameScript","The IDS Count shouldn't be more than 10!\n",LIGHT_RED);
|
||||
abort();
|
||||
error("GameScript", "The IDS Count shouldn't be more than 10!\n");
|
||||
}
|
||||
|
||||
ObjectIDSTableNames = (ieResRef *) malloc( sizeof(ieResRef) * ObjectIDSCount );
|
||||
@@ -1333,8 +1332,7 @@ void InitializeIEScript()
|
||||
}
|
||||
MaxObjectNesting = atoi( objNameTable->QueryField( 1 ) );
|
||||
if (MaxObjectNesting<0 || MaxObjectNesting>MAX_NESTING) {
|
||||
printMessage("GameScript","The Object Nesting Count shouldn't be more than 5!\n", LIGHT_RED);
|
||||
abort();
|
||||
error("GameScript", "The Object Nesting Count shouldn't be more than 5!\n");
|
||||
}
|
||||
HasAdditionalRect = ( atoi( objNameTable->QueryField( 2 ) ) != 0 );
|
||||
ExtraParametersCount = atoi( objNameTable->QueryField( 3 ) );
|
||||
@@ -1355,31 +1353,32 @@ void InitializeIEScript()
|
||||
while (j--) {
|
||||
i = triggersTable->GetValueIndex( j );
|
||||
const TriggerLink* poi = FindTrigger(triggersTable->GetStringIndex( j ));
|
||||
//maybe we should watch for this bit?
|
||||
//bool triggerflag = i & 0x4000;
|
||||
|
||||
bool was_condition = (i & 0x4000);
|
||||
i &= 0x3fff;
|
||||
if (i >= MAX_TRIGGERS) {
|
||||
printMessage("GameScript"," ", RED);
|
||||
printf("trigger %d (%s) is too high, ignoring\n", i, triggersTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "trigger %d (%s) is too high, ignoring\n", RED,
|
||||
i, triggersTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if (triggers[i]) {
|
||||
if (poi && triggers[i]!=poi->Function) {
|
||||
printMessage("GameScript"," ", YELLOW);
|
||||
printf("%s is in collision with ", triggersTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "%s is in collision with ", YELLOW,
|
||||
triggersTable->GetStringIndex( j ) );
|
||||
printFunction(triggersTable,triggersTable->FindValue(triggersTable->GetValueIndex( j )));
|
||||
//printFunction(triggersTable->GetStringIndex(triggersTable->FindValue(triggersTable->GetValueIndex( j )) ));
|
||||
} else {
|
||||
if (InDebug&ID_TRIGGERS) {
|
||||
printMessage("GameScript"," ", WHITE);
|
||||
printf("%s is a synonym of ", triggersTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "%s is a synonym of ", WHITE,
|
||||
triggersTable->GetStringIndex( j ) );
|
||||
printFunction(triggersTable,triggersTable->FindValue(triggersTable->GetValueIndex( j )));
|
||||
//printFunction(triggersTable->GetStringIndex(triggersTable->FindValue(triggersTable->GetValueIndex( j ) ) ) );
|
||||
}
|
||||
}
|
||||
continue; //we already found an alternative
|
||||
}
|
||||
|
||||
if (poi == NULL) {
|
||||
// missing trigger which might be resolved later
|
||||
triggers[i] = NULL;
|
||||
triggerflags[i] = 0;
|
||||
missing_triggers.push_back(j);
|
||||
@@ -1387,6 +1386,8 @@ void InitializeIEScript()
|
||||
}
|
||||
triggers[i] = poi->Function;
|
||||
triggerflags[i] = poi->Flags;
|
||||
if (was_condition)
|
||||
triggerflags[i] |= TF_CONDITION;
|
||||
}
|
||||
|
||||
for (l = missing_triggers.begin(); l!=missing_triggers.end();l++) {
|
||||
@@ -1402,38 +1403,38 @@ void InitializeIEScript()
|
||||
for (i = 0; triggernames[i].Name; i++) {
|
||||
if (f == triggernames[i].Function) {
|
||||
if (InDebug&ID_TRIGGERS) {
|
||||
printMessage("GameScript"," ", WHITE);
|
||||
printf("%s is a synonym of %s\n", triggersTable->GetStringIndex( j ), triggernames[i].Name );
|
||||
printMessage("GameScript", "%s is a synonym of %s\n", WHITE,
|
||||
triggersTable->GetStringIndex( j ), triggernames[i].Name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
printMessage("GameScript","Couldn't assign function to trigger: ", YELLOW);
|
||||
printFunction(triggersTable,j);
|
||||
//->GetStringIndex(j) );
|
||||
}
|
||||
|
||||
j = actionsTable->GetSize();
|
||||
while (j--) {
|
||||
i = actionsTable->GetValueIndex( j );
|
||||
if (i >= MAX_ACTIONS) {
|
||||
printMessage("GameScript"," ", RED);
|
||||
printf("action %d (%s) is too high, ignoring\n", i, actionsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "action %d (%s) is too high, ignoring\n", RED,
|
||||
i, actionsTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
const ActionLink* poi = FindAction( actionsTable->GetStringIndex( j ));
|
||||
if (actions[i]) {
|
||||
if (poi && actions[i]!=poi->Function) {
|
||||
printMessage("GameScript"," ", YELLOW);
|
||||
printf("%s is in collision with ", actionsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "%s is in collision with ", YELLOW,
|
||||
actionsTable->GetStringIndex( j ) );
|
||||
printFunction(actionsTable, actionsTable->FindValue(actionsTable->GetValueIndex(j)));
|
||||
//->GetStringIndex(actionsTable->FindValue(actionsTable->GetValueIndex( j )) ) );
|
||||
} else {
|
||||
if (InDebug&ID_ACTIONS) {
|
||||
printMessage("GameScript"," ", WHITE);
|
||||
printf("%s is a synonym of ", actionsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "%s is a synonym of ", WHITE,
|
||||
actionsTable->GetStringIndex( j ) );
|
||||
printFunction(actionsTable, actionsTable->FindValue(actionsTable->GetValueIndex( j )));
|
||||
//actionsTable->GetStringIndex(actionsTable->FindValue(actionsTable->GetValueIndex( j )) ) );
|
||||
}
|
||||
@@ -1459,8 +1460,8 @@ void InitializeIEScript()
|
||||
while (j--) {
|
||||
i = overrideActionsTable->GetValueIndex( j );
|
||||
if (i >= MAX_ACTIONS) {
|
||||
printMessage("GameScript"," ", RED);
|
||||
printf("action %d (%s) is too high, ignoring\n", i, overrideActionsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "action %d (%s) is too high, ignoring\n", RED,
|
||||
i, overrideActionsTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
const ActionLink *poi = FindAction( overrideActionsTable->GetStringIndex( j ));
|
||||
@@ -1468,8 +1469,8 @@ void InitializeIEScript()
|
||||
continue;
|
||||
}
|
||||
if (actions[i]) {
|
||||
printMessage("GameScript"," ", WHITE);
|
||||
printf("%s overrides existing action ", overrideActionsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "%s overrides existing action ", WHITE,
|
||||
overrideActionsTable->GetStringIndex( j ) );
|
||||
printFunction( actionsTable, actionsTable->FindValue(overrideActionsTable->GetValueIndex( j )));
|
||||
//printFunction( actionsTable->GetStringIndex(actionsTable->FindValue(overrideActionsTable->GetValueIndex( j )) ) );
|
||||
}
|
||||
@@ -1491,8 +1492,8 @@ void InitializeIEScript()
|
||||
for (i = 0; actionnames[i].Name; i++) {
|
||||
if (f == actionnames[i].Function) {
|
||||
if (InDebug&ID_ACTIONS) {
|
||||
printMessage("GameScript"," ", WHITE);
|
||||
printf("%s is a synonym of %s\n", actionsTable->GetStringIndex( j ), actionnames[i].Name );
|
||||
printMessage("GameScript", "%s is a synonym of %s\n", WHITE,
|
||||
actionsTable->GetStringIndex( j ), actionnames[i].Name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1508,20 +1509,20 @@ void InitializeIEScript()
|
||||
while (j--) {
|
||||
i = objectsTable->GetValueIndex( j );
|
||||
if (i >= MAX_OBJECTS) {
|
||||
printMessage("GameScript"," ", RED);
|
||||
printf("object %d (%s) is too high, ignoring\n", i, objectsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "object %d (%s) is too high, ignoring\n", RED,
|
||||
i, objectsTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
const ObjectLink* poi = FindObject( objectsTable->GetStringIndex( j ));
|
||||
if (objects[i]) {
|
||||
if (poi && objects[i]!=poi->Function) {
|
||||
printMessage("GameScript"," ", YELLOW);
|
||||
printf("%s is in collision with ", objectsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "%s is in collision with ", YELLOW,
|
||||
objectsTable->GetStringIndex( j ) );
|
||||
printFunction(objectsTable,objectsTable->FindValue(objectsTable->GetValueIndex( j )));
|
||||
//printFunction(objectsTable->GetStringIndex(objectsTable->FindValue(objectsTable->GetValueIndex( j )) ) );
|
||||
} else {
|
||||
printMessage("GameScript"," ", WHITE);
|
||||
printf("%s is a synonym of ", objectsTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "%s is a synonym of ", WHITE,
|
||||
objectsTable->GetStringIndex( j ) );
|
||||
printFunction(objectsTable, objectsTable->FindValue(objectsTable->GetValueIndex( j )));
|
||||
//printFunction(objectsTable->GetStringIndex(objectsTable->FindValue(objectsTable->GetValueIndex( j )) ) );
|
||||
}
|
||||
@@ -1547,8 +1548,8 @@ void InitializeIEScript()
|
||||
if (f) {
|
||||
for (i = 0; objectnames[i].Name; i++) {
|
||||
if (f == objectnames[i].Function) {
|
||||
printMessage("GameScript"," ", WHITE);
|
||||
printf("%s is a synonym of %s\n", objectsTable->GetStringIndex( j ), objectnames[i].Name );
|
||||
printMessage("GameScript", "%s is a synonym of %s\n", WHITE,
|
||||
objectsTable->GetStringIndex( j ), objectnames[i].Name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1561,29 +1562,54 @@ void InitializeIEScript()
|
||||
|
||||
int instantTableIndex = core->LoadSymbol("instant");
|
||||
if (instantTableIndex < 0) {
|
||||
printMessage("GameScript", "Couldn't find instant symbols!\n", LIGHT_RED);
|
||||
abort();
|
||||
error("GameScript", "Couldn't find instant symbols!\n");
|
||||
}
|
||||
Holder<SymbolMgr> instantTable = core->GetSymbol(instantTableIndex);
|
||||
if (!instantTable) {
|
||||
printMessage("GameScript", "Couldn't load instant symbols!\n", LIGHT_RED);
|
||||
abort();
|
||||
error("GameScript", "Couldn't load instant symbols!\n");
|
||||
}
|
||||
j = instantTable->GetSize();
|
||||
while (j--) {
|
||||
i = instantTable->GetValueIndex( j );
|
||||
if (i >= MAX_ACTIONS) {
|
||||
printMessage("GameScript"," ", RED);
|
||||
printf("instant action %d (%s) is too high, ignoring\n", i, instantTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "instant action %d (%s) is too high, ignoring\n", RED,
|
||||
i, instantTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
if (!actions[i]) {
|
||||
printMessage("GameScript"," ", YELLOW);
|
||||
printf("instant action %d (%s) doesn't exist, ignoring\n", i, instantTable->GetStringIndex( j ) );
|
||||
printMessage("GameScript", "instant action %d (%s) doesn't exist, ignoring\n", YELLOW,
|
||||
i, instantTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
actionflags[i] |= AF_INSTANT;
|
||||
}
|
||||
|
||||
int savedTriggersIndex = core->LoadSymbol("svtriobj");
|
||||
if (savedTriggersIndex < 0) {
|
||||
// leaving this as not strictly necessary, for now
|
||||
printMessage("GameScript", "Couldn't find saved trigger symbols!\n", YELLOW);
|
||||
} else {
|
||||
Holder<SymbolMgr> savedTriggersTable = core->GetSymbol(savedTriggersIndex);
|
||||
if (!savedTriggersTable) {
|
||||
error("GameScript", "Couldn't laod saved trigger symbols!\n");
|
||||
}
|
||||
j = savedTriggersTable->GetSize();
|
||||
while (j--) {
|
||||
i = savedTriggersTable->GetValueIndex( j );
|
||||
i &= 0x3fff;
|
||||
if (i >= MAX_ACTIONS) {
|
||||
printMessage("GameScript", "saved trigger %d (%s) is too high, ignoring\n", RED,
|
||||
i, savedTriggersTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
if (!triggers[i]) {
|
||||
printMessage("GameScript", "saved trigger %d (%s) doesn't exist, ignoring\n", YELLOW,
|
||||
i, savedTriggersTable->GetStringIndex( j ) );
|
||||
continue;
|
||||
}
|
||||
triggerflags[i] |= TF_SAVED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/********************** GameScript *******************************/
|
||||
@@ -1605,17 +1631,15 @@ GameScript::~GameScript(void)
|
||||
//set 3. parameter to true if you want instant free
|
||||
//and possible death
|
||||
if (InDebug&ID_REFERENCE) {
|
||||
printf("One instance of %s is dropped from %d.\n", Name, BcsCache.RefCount(Name) );
|
||||
print("One instance of %s is dropped from %d.\n", Name, BcsCache.RefCount(Name) );
|
||||
}
|
||||
int res = BcsCache.DecRef(script, Name, true);
|
||||
|
||||
if (res<0) {
|
||||
printMessage( "GameScript", "Corrupted Script cache encountered (reference count went below zero), ", LIGHT_RED );
|
||||
printf( "Script name is: %.8s\n", Name);
|
||||
abort();
|
||||
error("GameScript", "Corrupted Script cache encountered (reference count went below zero), Script name is: %.8s\n", Name);
|
||||
}
|
||||
if (!res) {
|
||||
//printf("Freeing script %s because its refcount has reached 0.\n", Name);
|
||||
//print("Freeing script %s because its refcount has reached 0.\n", Name);
|
||||
script->Release();
|
||||
}
|
||||
script = NULL;
|
||||
@@ -1631,7 +1655,7 @@ Script* GameScript::CacheScript(ieResRef ResRef, bool AIScript)
|
||||
Script *newScript = (Script *) BcsCache.GetResource(ResRef);
|
||||
if ( newScript ) {
|
||||
if (InDebug&ID_REFERENCE) {
|
||||
printf("Caching %s for the %d. time\n", ResRef, BcsCache.RefCount(ResRef) );
|
||||
print("Caching %s for the %d. time\n", ResRef, BcsCache.RefCount(ResRef) );
|
||||
}
|
||||
return newScript;
|
||||
}
|
||||
@@ -1649,7 +1673,7 @@ Script* GameScript::CacheScript(ieResRef ResRef, bool AIScript)
|
||||
newScript = new Script( );
|
||||
BcsCache.SetAt( ResRef, (void *) newScript );
|
||||
if (InDebug&ID_REFERENCE) {
|
||||
printf("Caching %s for the %d. time\n", ResRef, BcsCache.RefCount(ResRef) );
|
||||
print("Caching %s for the %d. time\n", ResRef, BcsCache.RefCount(ResRef) );
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@@ -1725,8 +1749,7 @@ static Object* DecodeObject(const char* line)
|
||||
oB->objectFields[i + ObjectFieldsCount] = ParseInt( line );
|
||||
}
|
||||
if (*line != 'O' || *(line + 1) != 'B') {
|
||||
printMessage( "GameScript","Got confused parsing object line: ", YELLOW );
|
||||
printf("%s\n", origline);
|
||||
printMessage("GameScript", "Got confused parsing object line: %s\n", YELLOW, origline);
|
||||
}
|
||||
//let the object realize it has no future (in case of null objects)
|
||||
if (oB->isNull()) {
|
||||
@@ -1807,7 +1830,7 @@ bool GameScript::Update(bool *continuing, bool *done)
|
||||
//lastRunTime = thisTime;
|
||||
|
||||
if(!(MySelf->GetInternalFlag()&IF_ACTIVE) ) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool continueExecution = false;
|
||||
@@ -1825,7 +1848,7 @@ bool GameScript::Update(bool *continuing, bool *done)
|
||||
if (MySelf->GetInternalFlag()&IF_NOINT) {
|
||||
// we presumably don't want any further execution?
|
||||
if (done) *done = true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lastAction==a) {
|
||||
@@ -1834,7 +1857,7 @@ bool GameScript::Update(bool *continuing, bool *done)
|
||||
// interactions with Continue() (lastAction here is always
|
||||
// the first block encountered), needs more testing
|
||||
//if (done) *done = true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//movetoobjectfollow would break if this isn't called
|
||||
@@ -1852,11 +1875,11 @@ bool GameScript::Update(bool *continuing, bool *done)
|
||||
if (continuing) *continuing = continueExecution;
|
||||
if (!continueExecution) {
|
||||
if (done) *done = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return continueExecution;
|
||||
}
|
||||
|
||||
//IE simply takes the first action's object for cutscene object
|
||||
@@ -1901,7 +1924,7 @@ void GameScript::EvaluateAllBlocks()
|
||||
rS->responses[0]->Execute(target);
|
||||
// TODO: this will break blocking instants, if there are any
|
||||
target->ReleaseCurrentAction();
|
||||
} else if (InDebug&ID_CUTSCENE) {
|
||||
} else if ((InDebug&ID_CUTSCENE) || !action->objects[1]) {
|
||||
printMessage("GameScript","Failed to find CutSceneID target!\n",YELLOW);
|
||||
if (action->objects[1]) {
|
||||
action->objects[1]->Dump();
|
||||
@@ -1957,14 +1980,14 @@ Response* GameScript::ReadResponse(DataStream* stream)
|
||||
}
|
||||
Response* rE = new Response();
|
||||
rE->weight = 0;
|
||||
int count = stream->ReadLine( line, 1024 );
|
||||
stream->ReadLine( line, 1024 );
|
||||
char *poi;
|
||||
rE->weight = (unsigned char)strtoul(line,&poi,10);
|
||||
if (strncmp(poi,"AC",2)==0)
|
||||
while (true) {
|
||||
//not autofreed, because it is referenced by the Script
|
||||
Action* aC = new Action(false);
|
||||
count = stream->ReadLine( line, 1024 );
|
||||
stream->ReadLine( line, 1024 );
|
||||
aC->actionID = (unsigned short)strtoul(line, NULL,10);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
stream->ReadLine( line, 1024 );
|
||||
@@ -2078,13 +2101,13 @@ int Trigger::Evaluate(Scriptable* Sender)
|
||||
if (!func) {
|
||||
triggers[triggerID] = GameScript::False;
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Unhandled trigger code: 0x%04x %s\n",
|
||||
print("Unhandled trigger code: 0x%04x %s\n",
|
||||
triggerID, tmpstr );
|
||||
return 0;
|
||||
}
|
||||
if (InDebug&ID_TRIGGERS) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf( "Executing trigger code: 0x%04x %s\n",
|
||||
print( "Executing trigger code: 0x%04x %s\n",
|
||||
triggerID, tmpstr );
|
||||
}
|
||||
int ret = func( Sender, this );
|
||||
@@ -2156,7 +2179,7 @@ int Response::Execute(Scriptable* Sender)
|
||||
|
||||
void PrintAction(int actionID)
|
||||
{
|
||||
printf("Action: %d %s\n", actionID , actionsTable->GetValue(actionID) );
|
||||
print("Action: %d %s\n", actionID , actionsTable->GetValue(actionID) );
|
||||
}
|
||||
|
||||
void GameScript::ExecuteAction(Scriptable* Sender, Action* aC)
|
||||
@@ -2171,8 +2194,8 @@ void GameScript::ExecuteAction(Scriptable* Sender, Action* aC)
|
||||
|
||||
if (scr) {
|
||||
if (InDebug&ID_ACTIONS) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Sender: %s-->override: %s\n",Sender->GetScriptName(), scr->GetScriptName() );
|
||||
printMessage("GameScript", "Sender: %s-->override: %s\n", YELLOW,
|
||||
Sender->GetScriptName(), scr->GetScriptName() );
|
||||
}
|
||||
scr->ReleaseCurrentAction();
|
||||
scr->AddAction(ParamCopyNoOverride(aC));
|
||||
@@ -2196,7 +2219,7 @@ void GameScript::ExecuteAction(Scriptable* Sender, Action* aC)
|
||||
if (InDebug&ID_ACTIONS) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
PrintAction(actionID);
|
||||
printf("Sender: %s\n",Sender->GetScriptName() );
|
||||
print("Sender: %s\n",Sender->GetScriptName() );
|
||||
}
|
||||
ActionFunction func = actions[actionID];
|
||||
if (func) {
|
||||
@@ -2227,7 +2250,7 @@ void GameScript::ExecuteAction(Scriptable* Sender, Action* aC)
|
||||
if (actionflags[actionID] & AF_IMMEDIATE) {
|
||||
//this action never entered the action queue, therefore shouldn't be freed
|
||||
if (aC->GetRef()!=1) {
|
||||
printf("Immediate action got queued!\n");
|
||||
print("Immediate action got queued!\n");
|
||||
PrintAction(actionID);
|
||||
abort();
|
||||
}
|
||||
@@ -2246,8 +2269,7 @@ Trigger* GenerateTrigger(char* String)
|
||||
{
|
||||
strlwr( String );
|
||||
if (InDebug&ID_TRIGGERS) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Compiling:%s\n",String);
|
||||
printMessage("GameScript", "Compiling:%s\n", YELLOW, String);
|
||||
}
|
||||
int negate = 0;
|
||||
if (*String == '!') {
|
||||
@@ -2257,16 +2279,14 @@ Trigger* GenerateTrigger(char* String)
|
||||
int len = strlench(String,'(')+1; //including (
|
||||
int i = triggersTable->FindString(String, len);
|
||||
if (i<0) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Invalid scripting trigger: %s\n", String);
|
||||
printMessage("GameScript", "Invalid scripting trigger: %s\n", LIGHT_RED, String);
|
||||
return NULL;
|
||||
}
|
||||
char *src = String+len;
|
||||
char *str = triggersTable->GetStringIndex( i )+len;
|
||||
Trigger *trigger = GenerateTriggerCore(src, str, i, negate);
|
||||
if (!trigger) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Malformed scripting trigger: %s\n", String);
|
||||
printMessage("GameScript", "Malformed scripting trigger: %s\n", LIGHT_RED, String);
|
||||
return NULL;
|
||||
}
|
||||
return trigger;
|
||||
@@ -2276,8 +2296,7 @@ Action* GenerateAction(char* String)
|
||||
{
|
||||
strlwr( String );
|
||||
if (InDebug&ID_ACTIONS) {
|
||||
printMessage("GameScript"," ",YELLOW);
|
||||
printf("Compiling:%s\n",String);
|
||||
printMessage("GameScript", "Compiling:%s\n", YELLOW, String);
|
||||
}
|
||||
int len = strlench(String,'(')+1; //including (
|
||||
char *src = String+len;
|
||||
@@ -2294,8 +2313,7 @@ Action* GenerateAction(char* String)
|
||||
if (i<0) {
|
||||
i = actionsTable->FindString(String, len);
|
||||
if (i < 0) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Invalid scripting action: %s\n", String);
|
||||
printMessage("GameScript", "Invalid scripting action: %s\n", LIGHT_RED, String);
|
||||
return NULL;
|
||||
}
|
||||
str = actionsTable->GetStringIndex( i )+len;
|
||||
@@ -2303,8 +2321,7 @@ Action* GenerateAction(char* String)
|
||||
}
|
||||
Action *action = GenerateActionCore( src, str, actionID);
|
||||
if (!action) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Malformed scripting action: %s\n", String);
|
||||
printMessage("GameScript", "Malformed scripting action: %s\n", LIGHT_RED, String);
|
||||
return NULL;
|
||||
}
|
||||
return action;
|
||||
|
||||
@@ -106,7 +106,7 @@ class GameScript;
|
||||
#define GSASSERT(f,c) \
|
||||
if(!(f)) \
|
||||
{ \
|
||||
printf("Assertion failed: %s [0x%08lX] Line %d",#f, c, __LINE__); \
|
||||
print("Assertion failed: %s [0x%08lX] Line %d",#f, c, __LINE__); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ class GEM_EXPORT Object {
|
||||
public:
|
||||
Object()
|
||||
{
|
||||
objectName[0] = 0;
|
||||
memset( objectName, 0, 65 );
|
||||
|
||||
memset( objectFields, 0, MAX_OBJECT_FIELDS * sizeof( int ) );
|
||||
memset( objectFilters, 0, MAX_NESTING * sizeof( int ) );
|
||||
@@ -171,19 +171,19 @@ public:
|
||||
|
||||
GSASSERT( canary == (unsigned long) 0xdeadbeef, canary );
|
||||
if(objectName[0]) {
|
||||
printf("Object: %s\n",objectName);
|
||||
print("Object: %s\n",objectName);
|
||||
return;
|
||||
}
|
||||
printf("IDS Targeting: ");
|
||||
print("IDS Targeting: ");
|
||||
for(i=0;i<MAX_OBJECT_FIELDS;i++) {
|
||||
printf("%d ",objectFields[i]);
|
||||
print("%d ",objectFields[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("Filters: ");
|
||||
print("\n");
|
||||
print("Filters: ");
|
||||
for(i=0;i<MAX_NESTING;i++) {
|
||||
printf("%d ",objectFilters[i]);
|
||||
print("%d ",objectFilters[i]);
|
||||
}
|
||||
printf("\n");
|
||||
print("\n");
|
||||
}
|
||||
|
||||
void Release()
|
||||
@@ -199,12 +199,14 @@ class GEM_EXPORT Trigger {
|
||||
public:
|
||||
Trigger()
|
||||
{
|
||||
triggerID = 0;
|
||||
flags = 0;
|
||||
objectParameter = NULL;
|
||||
string0Parameter[0] = 0;
|
||||
string1Parameter[0] = 0;
|
||||
memset(string0Parameter, 0, 65);
|
||||
memset(string1Parameter, 0, 65);
|
||||
int0Parameter = 0;
|
||||
int1Parameter = 0;
|
||||
int2Parameter = 0;
|
||||
pointParameter.null();
|
||||
canary = (unsigned long) 0xdeadbeef;
|
||||
}
|
||||
@@ -232,17 +234,17 @@ public:
|
||||
void Dump()
|
||||
{
|
||||
GSASSERT( canary == (unsigned long) 0xdeadbeef, canary );
|
||||
printf ("Trigger: %d\n", triggerID);
|
||||
printf ("Int parameters: %d %d %d\n", int0Parameter, int1Parameter, int2Parameter);
|
||||
printf ("Point: [%d.%d]\n", pointParameter.x, pointParameter.y);
|
||||
printf ("String0: %s\n", string0Parameter);
|
||||
printf ("String1: %s\n", string1Parameter);
|
||||
print ("Trigger: %d\n", triggerID);
|
||||
print ("Int parameters: %d %d %d\n", int0Parameter, int1Parameter, int2Parameter);
|
||||
print ("Point: [%d.%d]\n", pointParameter.x, pointParameter.y);
|
||||
print ("String0: %s\n", string0Parameter);
|
||||
print ("String1: %s\n", string1Parameter);
|
||||
if (objectParameter) {
|
||||
objectParameter->Dump();
|
||||
} else {
|
||||
printf("No object\n");
|
||||
print("No object\n");
|
||||
}
|
||||
printf("\n");
|
||||
print("\n");
|
||||
}
|
||||
|
||||
void Release()
|
||||
@@ -290,8 +292,8 @@ public:
|
||||
objects[0] = NULL;
|
||||
objects[1] = NULL;
|
||||
objects[2] = NULL;
|
||||
string0Parameter[0] = 0;
|
||||
string1Parameter[0] = 0;
|
||||
memset(string0Parameter, 0, 65);
|
||||
memset(string1Parameter, 0, 65);
|
||||
int0Parameter = 0;
|
||||
pointParameter.null();
|
||||
int1Parameter = 0;
|
||||
@@ -334,25 +336,25 @@ public:
|
||||
int i;
|
||||
|
||||
GSASSERT( canary == (unsigned long) 0xdeadbeef, canary );
|
||||
printf("Int0: %d, Int1: %d, Int2: %d\n",int0Parameter, int1Parameter, int2Parameter);
|
||||
printf("String0: %s, String1: %s\n", string0Parameter?string0Parameter:"<NULL>", string1Parameter?string1Parameter:"<NULL>");
|
||||
print("Int0: %d, Int1: %d, Int2: %d\n",int0Parameter, int1Parameter, int2Parameter);
|
||||
print("String0: %s, String1: %s\n", string0Parameter?string0Parameter:"<NULL>", string1Parameter?string1Parameter:"<NULL>");
|
||||
for (i=0;i<3;i++) {
|
||||
if (objects[i]) {
|
||||
printf( "%d. ",i+1);
|
||||
print( "%d. ",i+1);
|
||||
objects[i]->Dump();
|
||||
} else {
|
||||
printf( "%d. Object - NULL\n",i+1);
|
||||
print( "%d. Object - NULL\n",i+1);
|
||||
}
|
||||
}
|
||||
|
||||
printf("RefCount: %d\n", RefCount);
|
||||
print("RefCount: %d\n", RefCount);
|
||||
}
|
||||
|
||||
void Release()
|
||||
{
|
||||
GSASSERT( canary == (unsigned long) 0xdeadbeef, canary );
|
||||
if (!RefCount) {
|
||||
printf( "WARNING!!! Double Freeing in %s: Line %d\n", __FILE__,
|
||||
print( "WARNING!!! Double Freeing in %s: Line %d\n", __FILE__,
|
||||
__LINE__ );
|
||||
abort();
|
||||
}
|
||||
@@ -367,7 +369,7 @@ public:
|
||||
GSASSERT( canary == (unsigned long) 0xdeadbeef, canary );
|
||||
RefCount++;
|
||||
if (RefCount >= 65536) {
|
||||
printf( "Refcount increased to: %d in action %d\n", RefCount,
|
||||
print( "Refcount increased to: %d in action %d\n", RefCount,
|
||||
actionID );
|
||||
abort();
|
||||
}
|
||||
@@ -386,7 +388,7 @@ public:
|
||||
for (size_t c = 0; c < actions.size(); c++) {
|
||||
if (actions[c]) {
|
||||
if (actions[c]->GetRef()>2) {
|
||||
printf("Residue action %d with refcount %d\n", actions[c]->actionID, actions[c]->GetRef());
|
||||
print("Residue action %d with refcount %d\n", actions[c]->actionID, actions[c]->GetRef());
|
||||
}
|
||||
actions[c]->Release();
|
||||
actions[c] = NULL;
|
||||
@@ -503,6 +505,7 @@ typedef int (* IDSFunction)(Actor *, int parameter);
|
||||
|
||||
#define TF_NONE 0
|
||||
#define TF_CONDITION 1 //this isn't a trigger, just a condition (0x4000)
|
||||
#define TF_SAVED 2 //trigger is in svtriobj.ids
|
||||
#define TF_MERGESTRINGS 8 //same value as actions' mergestring
|
||||
|
||||
struct TriggerLink {
|
||||
@@ -786,6 +789,7 @@ public: //Script Functions
|
||||
static int ItemIsIdentified(Scriptable* Sender, Trigger* parameters);
|
||||
static int Joins(Scriptable* Sender, Trigger* parameters);
|
||||
static int Kit(Scriptable* Sender, Trigger* parameters);
|
||||
static int Killed(Scriptable* Sender, Trigger* parameters);
|
||||
static int KnowSpell(Scriptable* Sender, Trigger* parameters);
|
||||
static int LastMarkedObject_Trigger(Scriptable* Sender, Trigger* parameters);
|
||||
static int LastPersonTalkedTo(Scriptable* Sender, Trigger* parameters);
|
||||
@@ -1037,6 +1041,7 @@ public:
|
||||
static void DayNight(Scriptable *Sender, Action* parameters);
|
||||
static void Deactivate(Scriptable* Sender, Action* parameters);
|
||||
static void Debug(Scriptable* Sender, Action* parameters);
|
||||
static void DemoEnd(Scriptable* Sender, Action* parameters);
|
||||
static void DestroyAllDestructableEquipment(Scriptable* Sender,
|
||||
Action* parameters);
|
||||
static void DestroyAllEquipment(Scriptable* Sender, Action* parameters);
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Game.h"
|
||||
#include "Map.h"
|
||||
#include "TileMap.h"
|
||||
#include "Scriptable/Container.h"
|
||||
#include "Scriptable/Door.h"
|
||||
#include "Scriptable/InfoPoint.h"
|
||||
|
||||
/* return a Targets object with a single scriptable inside */
|
||||
inline static Targets* ReturnScriptableAsTarget(Scriptable *sc)
|
||||
static inline Targets* ReturnScriptableAsTarget(Scriptable *sc)
|
||||
{
|
||||
if (!sc) return NULL;
|
||||
Targets *tgts = new Targets();
|
||||
@@ -39,7 +40,7 @@ inline static Targets* ReturnScriptableAsTarget(Scriptable *sc)
|
||||
}
|
||||
|
||||
/* do IDS filtering: [PC], [ENEMY], etc */
|
||||
inline static bool DoObjectIDSCheck(Object *oC, Actor *ac, bool *filtered) {
|
||||
static inline bool DoObjectIDSCheck(Object *oC, Actor *ac, bool *filtered) {
|
||||
for (int j = 0; j < ObjectIDSCount; j++) {
|
||||
if (!oC->objectFields[j]) {
|
||||
continue;
|
||||
@@ -47,8 +48,7 @@ inline static bool DoObjectIDSCheck(Object *oC, Actor *ac, bool *filtered) {
|
||||
*filtered = true;
|
||||
IDSFunction func = idtargets[j];
|
||||
if (!func) {
|
||||
printMessage("GameScript"," ", YELLOW);
|
||||
printf("Unimplemented IDS targeting opcode: %d\n", j);
|
||||
printMessage("GameScript", "Unimplemented IDS targeting opcode: %d\n", YELLOW, j);
|
||||
continue;
|
||||
}
|
||||
if (!func( ac, oC->objectFields[j] ) ) {
|
||||
@@ -59,15 +59,15 @@ inline static bool DoObjectIDSCheck(Object *oC, Actor *ac, bool *filtered) {
|
||||
}
|
||||
|
||||
/* do object filtering: Myself, LastAttackerOf(Player1), etc */
|
||||
inline static Targets *DoObjectFiltering(Scriptable *Sender, Targets *tgts, Object *oC, int ga_flags) {
|
||||
static inline Targets *DoObjectFiltering(Scriptable *Sender, Targets *tgts, Object *oC, int ga_flags) {
|
||||
for (int i = 0; i < MaxObjectNesting; i++) {
|
||||
int filterid = oC->objectFilters[i];
|
||||
if (!filterid) break;
|
||||
|
||||
ObjectFunction func = objects[filterid];
|
||||
if (!func) {
|
||||
printMessage("GameScript"," ", YELLOW);
|
||||
printf("Unknown object filter: %d %s\n", filterid, objectsTable->GetValue(filterid));
|
||||
printMessage("GameScript", "Unknown object filter: %d %s\n", YELLOW,
|
||||
filterid, objectsTable->GetValue(filterid));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ inline static Targets *DoObjectFiltering(Scriptable *Sender, Targets *tgts, Obje
|
||||
|
||||
static EffectRef fx_protection_creature_ref = { "Protection:Creature", -1 };
|
||||
|
||||
inline static bool DoObjectChecks(Map *map, Scriptable *Sender, Actor *target, int &dist, bool ignoreinvis=false)
|
||||
static inline bool DoObjectChecks(Map *map, Scriptable *Sender, Actor *target, int &dist, bool ignoreinvis=false)
|
||||
{
|
||||
dist = SquaredMapDistance(Sender, target);
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "exports.h"
|
||||
|
||||
class TileMap;
|
||||
|
||||
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);
|
||||
|
||||
@@ -137,8 +137,8 @@ Targets *GameScript::Gabber(Scriptable* /*Sender*/, Targets *parameters, int ga_
|
||||
Targets *GameScript::LastTrigger(Scriptable *Sender, Targets *parameters, int ga_flags)
|
||||
{
|
||||
parameters->Clear();
|
||||
if (Sender->LastTriggerObject) {
|
||||
Actor *target = Sender->GetCurrentArea()->GetActorByGlobalID(Sender->LastTriggerObject);
|
||||
if (Sender->LastTrigger) {
|
||||
Actor *target = Sender->GetCurrentArea()->GetActorByGlobalID(Sender->LastTrigger);
|
||||
parameters->AddTarget(target, 0, ga_flags);
|
||||
}
|
||||
return parameters;
|
||||
@@ -252,7 +252,7 @@ Targets *GameScript::ProtectorOf(Scriptable *Sender, Targets *parameters, int ga
|
||||
}
|
||||
}
|
||||
parameters->Clear();
|
||||
if (actor) {
|
||||
/*if (actor) {
|
||||
ieWord tmp = actor->LastProtected;
|
||||
Map *cm = Sender->GetCurrentArea();
|
||||
int i = cm->GetActorCount(true);
|
||||
@@ -262,6 +262,12 @@ Targets *GameScript::ProtectorOf(Scriptable *Sender, Targets *parameters, int ga
|
||||
parameters->AddTarget(target, 0, ga_flags);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (actor) {
|
||||
Actor *target = actor->GetCurrentArea()->GetActorByGlobalID(actor->LastProtector);
|
||||
if (target) {
|
||||
parameters->AddTarget(target, 0, ga_flags);
|
||||
}
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
@@ -276,7 +282,7 @@ Targets *GameScript::ProtectedBy(Scriptable *Sender, Targets *parameters, int ga
|
||||
}
|
||||
parameters->Clear();
|
||||
if (actor) {
|
||||
Actor *target = actor->GetCurrentArea()->GetActorByGlobalID(actor->LastProtected);
|
||||
Actor *target = actor->GetCurrentArea()->GetActorByGlobalID(actor->LastProtectee);
|
||||
if (target) {
|
||||
parameters->AddTarget(target, 0, ga_flags);
|
||||
}
|
||||
@@ -325,7 +331,7 @@ Targets *GameScript::LastAttackerOf(Scriptable *Sender, Targets *parameters, int
|
||||
}
|
||||
parameters->Clear();
|
||||
if (actor) {
|
||||
Actor *target = actor->GetCurrentArea()->GetActorByGlobalID(actor->LastHitter);
|
||||
Actor *target = actor->GetCurrentArea()->GetActorByGlobalID(actor->LastAttacker);
|
||||
if (target) {
|
||||
parameters->AddTarget(target, 0, ga_flags);
|
||||
}
|
||||
@@ -379,7 +385,7 @@ Targets *GameScript::LastTalkedToBy(Scriptable *Sender, Targets *parameters, int
|
||||
}
|
||||
parameters->Clear();
|
||||
if (actor) {
|
||||
Actor *target = actor->GetCurrentArea()->GetActorByGlobalID(actor->LastTalkedTo);
|
||||
Actor *target = actor->GetCurrentArea()->GetActorByGlobalID(actor->LastTalker);
|
||||
if (target) {
|
||||
parameters->AddTarget(target, 0, ga_flags);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "DialogHandler.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "Polygon.h"
|
||||
#include "Video.h"
|
||||
#include "GUI/GameControl.h"
|
||||
#include "math.h" //needs for acos
|
||||
@@ -811,20 +812,12 @@ int GameScript::GlobalTimerStarted(Scriptable* Sender, Trigger* parameters)
|
||||
|
||||
int GameScript::WasInDialog(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
{
|
||||
if (Sender->GetInternalFlag()&IF_WASINDIALOG) {
|
||||
Sender->SetBitTrigger(BT_WASINDIALOG);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTrigger(trigger_wasindialog);
|
||||
}
|
||||
|
||||
int GameScript::OnCreation(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
{
|
||||
if (Sender->GetInternalFlag()&IF_ONCREATION) {
|
||||
Sender->SetBitTrigger(BT_ONCREATION);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTrigger(trigger_oncreation);
|
||||
}
|
||||
|
||||
int GameScript::NumItemsParty(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
@@ -1549,16 +1542,12 @@ int GameScript::Or(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
|
||||
int GameScript::TriggerTrigger(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if(Sender->TriggerID==(ieDword) parameters->int0Parameter) {
|
||||
Sender->AddTrigger (&Sender->TriggerID);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTrigger(trigger_trigger, parameters->int0Parameter);
|
||||
}
|
||||
|
||||
int GameScript::WalkedToTrigger(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
Actor *target = Sender->GetCurrentArea()->GetActorByGlobalID(Sender->LastTrigger);
|
||||
/*Actor *target = Sender->GetCurrentArea()->GetActorByGlobalID(Sender->LastTrigger);
|
||||
if (!target) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1575,293 +1564,72 @@ int GameScript::WalkedToTrigger(Scriptable* Sender, Trigger* parameters)
|
||||
Sender->AddTrigger (&Sender->LastTrigger);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
return Sender->MatchTriggerWithObject(trigger_walkedtotrigger, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::Clicked(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
//now objects suicide themselves if they are empty objects
|
||||
//so checking an empty object is easier
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastTrigger) {
|
||||
Sender->AddTrigger (&Sender->LastTrigger);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastTrigger, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastTrigger);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_clicked, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::Disarmed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
switch(Sender->Type) {
|
||||
case ST_DOOR: case ST_CONTAINER: case ST_PROXIMITY:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastDisarmed) {
|
||||
Sender->AddTrigger (&Sender->LastDisarmed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastDisarmed, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastDisarmed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_disarmed, parameters->objectParameter);
|
||||
}
|
||||
|
||||
//stealing from a store failed, owner triggered
|
||||
int GameScript::StealFailed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
switch(Sender->Type) {
|
||||
case ST_ACTOR:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
// maybe check if Sender is a shopkeeper???
|
||||
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastDisarmFailed) {
|
||||
Sender->AddTrigger (&Sender->LastDisarmFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastDisarmFailed, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastDisarmFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_disarmfailed, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::PickpocketFailed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
switch(Sender->Type) {
|
||||
case ST_ACTOR:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastOpenFailed) {
|
||||
Sender->AddTrigger (&Sender->LastOpenFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastOpenFailed, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastOpenFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_pickpocketfailed, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::PickLockFailed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
switch(Sender->Type) {
|
||||
case ST_DOOR: case ST_CONTAINER:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastPickLockFailed) {
|
||||
Sender->AddTrigger (&Sender->LastPickLockFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastPickLockFailed, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastPickLockFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_picklockfailed, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::OpenFailed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
switch(Sender->Type) {
|
||||
case ST_DOOR: case ST_CONTAINER:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastOpenFailed) {
|
||||
Sender->AddTrigger (&Sender->LastOpenFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastOpenFailed, parameters->objectParameter
|
||||
)) {
|
||||
Sender->AddTrigger (&Sender->LastOpenFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_failedtoopen, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::DisarmFailed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
switch(Sender->Type) {
|
||||
case ST_DOOR: case ST_CONTAINER: case ST_PROXIMITY:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastDisarmFailed) {
|
||||
Sender->AddTrigger (&Sender->LastDisarmFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastDisarmFailed, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastDisarmFailed);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_disarmfailed, parameters->objectParameter);
|
||||
}
|
||||
|
||||
//opened for doors/containers (using lastEntered)
|
||||
int GameScript::Opened(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
Door *door;
|
||||
|
||||
switch (Sender->Type) {
|
||||
case ST_DOOR:
|
||||
door = (Door *) Sender;
|
||||
if (!door->IsOpen()) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case ST_CONTAINER:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastEntered) {
|
||||
Sender->AddTrigger (&Sender->LastEntered);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastEntered, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastEntered);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_opened, parameters->objectParameter);
|
||||
}
|
||||
|
||||
//closed for doors (using lastTrigger)
|
||||
int GameScript::Closed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type != ST_DOOR) {
|
||||
return 0;
|
||||
}
|
||||
Door *door = (Door *) Sender;
|
||||
if (door->IsOpen()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastTrigger) {
|
||||
Sender->AddTrigger (&Sender->LastTrigger);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastTrigger, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastTrigger);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_closed, parameters->objectParameter);
|
||||
}
|
||||
|
||||
//unlocked for doors/containers (using lastUnlocked)
|
||||
int GameScript::Unlocked(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
Door *door;
|
||||
|
||||
switch (Sender->Type) {
|
||||
case ST_DOOR:
|
||||
door = (Door *) Sender;
|
||||
if ((door->Flags&DOOR_LOCKED) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case ST_CONTAINER:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastUnlocked) {
|
||||
Sender->AddTrigger (&Sender->LastUnlocked);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastUnlocked, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastUnlocked);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_unlocked, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::Entered(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type != ST_PROXIMITY) {
|
||||
return 0;
|
||||
}
|
||||
InfoPoint *ip = (InfoPoint *) Sender;
|
||||
if (!ip->Trapped) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastEntered) {
|
||||
Sender->AddTrigger (&Sender->LastEntered);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastEntered, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastEntered);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_entered, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::HarmlessEntered(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type != ST_PROXIMITY) {
|
||||
return 0;
|
||||
}
|
||||
if (parameters->objectParameter == NULL) {
|
||||
if (Sender->LastEntered) {
|
||||
Sender->AddTrigger (&Sender->LastEntered);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (MatchActor(Sender, Sender->LastEntered, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastEntered);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_harmlessentered, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::IsOverMe(Scriptable* Sender, Trigger* parameters)
|
||||
@@ -1944,68 +1712,32 @@ int GameScript::CreatureHidden(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
}
|
||||
int GameScript::BecameVisible(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor *act=(Actor *) Sender;
|
||||
if (act->GetInternalFlag()&IF_BECAMEVISIBLE) {
|
||||
//set trigger to erase
|
||||
act->SetBitTrigger(BT_BECAMEVISIBLE);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTrigger(trigger_becamevisible);
|
||||
}
|
||||
|
||||
int GameScript::Die(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor *act=(Actor *) Sender;
|
||||
if (act->GetInternalFlag()&IF_JUSTDIED) {
|
||||
//set trigger to erase
|
||||
act->SetBitTrigger(BT_DIE);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTrigger(trigger_die);
|
||||
}
|
||||
|
||||
int GameScript::Died(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter );
|
||||
if (!tar || tar->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor *act=(Actor *) tar;
|
||||
if (act->GetInternalFlag()&IF_JUSTDIED) {
|
||||
//set trigger to erase
|
||||
act->SetBitTrigger(BT_DIE);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_died, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::PartyMemberDied(Scriptable* /*Sender*/, Trigger* /*parameters*/)
|
||||
int GameScript::PartyMemberDied(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
Game *game = core->GetGame();
|
||||
int i = game->PartyMemberDied();
|
||||
if (i==-1) {
|
||||
return 0;
|
||||
}
|
||||
//set trigger to erase
|
||||
game->GetPC(i,false)->SetBitTrigger(BT_DIE);
|
||||
return 1;
|
||||
return Sender->MatchTriggerWithObject(trigger_partymemberdied, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::NamelessBitTheDust(Scriptable* /*Sender*/, Trigger* /*parameters*/)
|
||||
int GameScript::NamelessBitTheDust(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
{
|
||||
Actor* actor = core->GetGame()->GetPC(0, false);
|
||||
if (actor->GetInternalFlag()&IF_JUSTDIED) {
|
||||
//set trigger to clear
|
||||
actor->SetBitTrigger(BT_DIE);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTrigger(trigger_namelessbitthedust);
|
||||
}
|
||||
|
||||
int GameScript::Killed(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
return Sender->MatchTriggerWithObject(trigger_killed, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::Race(Scriptable* Sender, Trigger* parameters)
|
||||
@@ -2450,6 +2182,7 @@ int GameScript::See(Scriptable* Sender, Trigger* parameters)
|
||||
if (Sender->Type==ST_ACTOR && see) {
|
||||
Actor *act = (Actor *) Sender;
|
||||
//save lastseen as lastmarked
|
||||
//FIXME: what is this doing?
|
||||
act->LastMarked = act->LastSeen;
|
||||
//Sender->AddTrigger (&act->LastSeen);
|
||||
}
|
||||
@@ -2697,9 +2430,9 @@ int GameScript::OpenState(Scriptable* Sender, Trigger* parameters)
|
||||
Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter );
|
||||
if (!tar) {
|
||||
if (InDebug&ID_TRIGGERS) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Couldn't find door/container:%s\n", parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>");
|
||||
printf("Sender: %s\n", Sender->GetScriptName() );
|
||||
printMessage("GameScript", "Couldn't find door/container:%s\n", LIGHT_RED,
|
||||
parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>");
|
||||
print("Sender: %s\n", Sender->GetScriptName() );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -2716,8 +2449,8 @@ int GameScript::OpenState(Scriptable* Sender, Trigger* parameters)
|
||||
}
|
||||
default:; //to remove a warning
|
||||
}
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Not a door/container:%s\n", tar->GetScriptName());
|
||||
printMessage("GameScript", "Not a door/container:%s\n", LIGHT_RED,
|
||||
tar->GetScriptName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2725,9 +2458,9 @@ int GameScript::IsLocked(Scriptable * Sender, Trigger *parameters)
|
||||
{
|
||||
Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter );
|
||||
if (!tar) {
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Couldn't find door/container:%s\n", parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>");
|
||||
printf("Sender: %s\n", Sender->GetScriptName() );
|
||||
printMessage("GameScript", "Couldn't find door/container:%s\n", LIGHT_RED,
|
||||
parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>");
|
||||
print("Sender: %s\n", Sender->GetScriptName() );
|
||||
return 0;
|
||||
}
|
||||
switch(tar->Type) {
|
||||
@@ -2743,8 +2476,8 @@ int GameScript::IsLocked(Scriptable * Sender, Trigger *parameters)
|
||||
}
|
||||
default:; //to remove a warning
|
||||
}
|
||||
printMessage("GameScript"," ",LIGHT_RED);
|
||||
printf("Not a door/container:%s\n", tar->GetScriptName());
|
||||
printMessage("GameScript", "Not a door/container:%s\n", LIGHT_RED,
|
||||
tar->GetScriptName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3397,18 +3130,7 @@ int GameScript::TimeLT(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
|
||||
int GameScript::HotKey(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type != ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor *scr = (Actor *) Sender;
|
||||
// FIXME: this is never going to work on 64 bit archs ...
|
||||
int ret = (unsigned long) scr->HotKey == (unsigned long) parameters->int0Parameter;
|
||||
//probably we need to implement a trigger mechanism, clear
|
||||
//the hotkey only when the triggerblock was evaluated as true
|
||||
if (ret) {
|
||||
Sender->AddTrigger (&scr->HotKey);
|
||||
}
|
||||
return ret;
|
||||
return Sender->MatchTrigger(trigger_hotkey, parameters->int0Parameter);
|
||||
}
|
||||
|
||||
int GameScript::CombatCounter(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
@@ -3428,20 +3150,7 @@ int GameScript::CombatCounterLT(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
|
||||
int GameScript::TrapTriggered(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type != ST_TRIGGER) {
|
||||
return 0;
|
||||
}
|
||||
/* matchactor would do this, hmm
|
||||
Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter );
|
||||
if (!tar || tar->Type != ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
if (MatchActor(Sender, Sender->LastTrigger, parameters->objectParameter)) {
|
||||
Sender->AddTrigger (&Sender->LastTrigger);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_traptriggered, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::InteractingWith(Scriptable* Sender, Trigger* parameters)
|
||||
@@ -3473,7 +3182,7 @@ int GameScript::LastPersonTalkedTo(Scriptable* Sender, Trigger* parameters)
|
||||
return 0;
|
||||
}
|
||||
Actor *scr = (Actor *) Sender;
|
||||
if (MatchActor(Sender, scr->LastTalkedTo, parameters->objectParameter)) {
|
||||
if (MatchActor(Sender, scr->LastTalker, parameters->objectParameter)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -3525,7 +3234,8 @@ int GameScript::IsFacingObject(Scriptable* Sender, Trigger* parameters)
|
||||
|
||||
int GameScript::AttackedBy(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return Sender->MatchTriggerWithObject(trigger_attackedby, parameters->objectParameter, parameters->int0Parameter);
|
||||
/*if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor *scr = (Actor *) Sender;
|
||||
@@ -3550,12 +3260,13 @@ int GameScript::AttackedBy(Scriptable* Sender, Trigger* parameters)
|
||||
}
|
||||
}
|
||||
delete tgts;
|
||||
return ret;
|
||||
return ret;*/
|
||||
}
|
||||
|
||||
int GameScript::TookDamage(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return Sender->MatchTrigger(trigger_tookdamage);
|
||||
/*if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
@@ -3564,43 +3275,17 @@ int GameScript::TookDamage(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
Sender->AddTrigger(&actor->LastHitter);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
int GameScript::HitBy(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
if (parameters->int0Parameter) {
|
||||
if (!(parameters->int0Parameter&actor->LastDamageType) ) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (MatchActor(Sender, actor->LastHitter, parameters->objectParameter)) {
|
||||
Sender->AddTrigger(&actor->LastHitter);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_attackedby, parameters->objectParameter, parameters->int0Parameter);
|
||||
}
|
||||
|
||||
int GameScript::Heard(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
if (parameters->int0Parameter) {
|
||||
if (parameters->int0Parameter!=actor->LastShout) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (MatchActor(Sender, actor->LastHeard, parameters->objectParameter)) {
|
||||
Sender->AddTrigger(&actor->LastHeard);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_heard, parameters->objectParameter, parameters->int0Parameter);
|
||||
}
|
||||
|
||||
int GameScript::LastMarkedObject_Trigger(Scriptable* Sender, Trigger* parameters)
|
||||
@@ -3645,7 +3330,8 @@ int GameScript::HelpEX(Scriptable* Sender, Trigger* parameters)
|
||||
return 0;
|
||||
}
|
||||
if (actor->GetStat(stat)==help->GetStat(stat) ) {
|
||||
Sender->AddTrigger(&actor->LastHelp);
|
||||
// FIXME
|
||||
//Sender->AddTrigger(&actor->LastHelp);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -3653,30 +3339,18 @@ int GameScript::HelpEX(Scriptable* Sender, Trigger* parameters)
|
||||
|
||||
int GameScript::Help_Trigger(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
if (MatchActor(Sender, actor->LastHelp, parameters->objectParameter)) {
|
||||
Sender->AddTrigger(&actor->LastHelp);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_help, parameters->objectParameter);
|
||||
}
|
||||
|
||||
int GameScript::ReceivedOrder(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (MatchActor(Sender, Sender->LastOrderer, parameters->objectParameter) &&
|
||||
parameters->int0Parameter==Sender->LastOrder) {
|
||||
Sender->AddTrigger(&Sender->LastOrderer);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_receivedorder, parameters->objectParameter, parameters->int0Parameter);
|
||||
}
|
||||
|
||||
int GameScript::Joins(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if(Sender->Type!=ST_ACTOR) {
|
||||
return Sender->MatchTriggerWithObject(trigger_joins, parameters->objectParameter);
|
||||
/*if(Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor * actor = ( Actor* ) Sender;
|
||||
@@ -3688,12 +3362,13 @@ int GameScript::Joins(Scriptable* Sender, Trigger* parameters)
|
||||
Sender->AddTrigger(&actor->PCStats->LastJoined);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
int GameScript::Leaves(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if(Sender->Type!=ST_ACTOR) {
|
||||
return Sender->MatchTriggerWithObject(trigger_leaves, parameters->objectParameter);
|
||||
/*if(Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor * actor = ( Actor* ) Sender;
|
||||
@@ -3705,7 +3380,7 @@ int GameScript::Leaves(Scriptable* Sender, Trigger* parameters)
|
||||
Sender->AddTrigger(&actor->PCStats->LastLeft);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
int GameScript::FallenPaladin(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
@@ -4115,13 +3790,8 @@ int GameScript::Delay( Scriptable* Sender, Trigger* parameters)
|
||||
if (delay<=1) {
|
||||
return 1;
|
||||
}
|
||||
ieDword time1=Sender->lastDelay/1000/delay;
|
||||
ieDword time2=Sender->lastRunTime/1000/delay;
|
||||
|
||||
if (time1!=time2) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return (Sender->ScriptTicks % delay) <= Sender->IdleTicks;
|
||||
}
|
||||
|
||||
int GameScript::TimeOfDay(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
@@ -4164,11 +3834,7 @@ int GameScript::RandomStatCheck(Scriptable* Sender, Trigger* parameters)
|
||||
|
||||
int GameScript::PartyRested(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
{
|
||||
if (Sender->GetInternalFlag()&IF_PARTYRESTED) {
|
||||
Sender->SetBitTrigger(BT_PARTYRESTED);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTrigger(trigger_partyrested);
|
||||
}
|
||||
|
||||
int GameScript::IsWeaponRanged(Scriptable* Sender, Trigger* parameters)
|
||||
@@ -4344,7 +4010,8 @@ int GameScript::SystemVariable_Trigger(Scriptable* Sender, Trigger* parameters)
|
||||
|
||||
int GameScript::SpellCast(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if(parameters->int0Parameter) {
|
||||
return Sender->MatchTriggerWithObject(trigger_spellcast, parameters->objectParameter, parameters->int0Parameter);
|
||||
/*if(parameters->int0Parameter) {
|
||||
unsigned int param = 2000+parameters->int0Parameter%1000;
|
||||
if (param!=Sender->LastSpellSeen) {
|
||||
return 0;
|
||||
@@ -4354,12 +4021,13 @@ int GameScript::SpellCast(Scriptable* Sender, Trigger* parameters)
|
||||
Sender->AddTrigger(&Sender->LastCasterSeen);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
int GameScript::SpellCastPriest(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if(parameters->int0Parameter) {
|
||||
return Sender->MatchTriggerWithObject(trigger_spellcastpriest, parameters->objectParameter, parameters->int0Parameter);
|
||||
/*if(parameters->int0Parameter) {
|
||||
unsigned int param = 1000+parameters->int0Parameter%1000;
|
||||
if (param!=Sender->LastSpellSeen) {
|
||||
return 0;
|
||||
@@ -4369,12 +4037,13 @@ int GameScript::SpellCastPriest(Scriptable* Sender, Trigger* parameters)
|
||||
Sender->AddTrigger(&Sender->LastCasterSeen);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
int GameScript::SpellCastInnate(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if(parameters->int0Parameter) {
|
||||
return Sender->MatchTriggerWithObject(trigger_spellcastinnate, parameters->objectParameter, parameters->int0Parameter);
|
||||
/*if(parameters->int0Parameter) {
|
||||
unsigned int param = 3000+parameters->int0Parameter%1000;
|
||||
if (param!=Sender->LastSpellSeen) {
|
||||
return 0;
|
||||
@@ -4384,12 +4053,13 @@ int GameScript::SpellCastInnate(Scriptable* Sender, Trigger* parameters)
|
||||
Sender->AddTrigger(&Sender->LastCasterSeen);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
int GameScript::SpellCastOnMe(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if(parameters->int0Parameter) {
|
||||
return Sender->MatchTriggerWithObject(trigger_spellcastonme, parameters->objectParameter, parameters->int0Parameter);
|
||||
/*if(parameters->int0Parameter) {
|
||||
if ((ieDword) parameters->int0Parameter!=Sender->LastSpellOnMe) {
|
||||
return 0;
|
||||
}
|
||||
@@ -4398,7 +4068,7 @@ int GameScript::SpellCastOnMe(Scriptable* Sender, Trigger* parameters)
|
||||
Sender->AddTrigger(&Sender->LastCasterOnMe);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
int GameScript::CalendarDay(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
@@ -4429,15 +4099,7 @@ int GameScript::CalendarDayLT(Scriptable* /*Sender*/, Trigger* parameters)
|
||||
}
|
||||
|
||||
//NT Returns true only if the active CRE was turned by the specified priest or paladin.
|
||||
int GameScript::TurnedBy(Scriptable* Sender, Trigger* /*parameters*/)
|
||||
int GameScript::TurnedBy(Scriptable* Sender, Trigger* parameters)
|
||||
{
|
||||
if (Sender->Type!=ST_ACTOR) {
|
||||
return 0;
|
||||
}
|
||||
Actor* actor = ( Actor* ) Sender;
|
||||
if (MatchActor(Sender, actor->LastTurner, NULL)) {
|
||||
Sender->AddTrigger(&actor->LastTurner);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Sender->MatchTriggerWithObject(trigger_turnedby, parameters->objectParameter);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void GlobalTimer::Freeze()
|
||||
unsigned long thisTime;
|
||||
unsigned long advance;
|
||||
|
||||
GetTime( thisTime );
|
||||
thisTime = GetTickCount();
|
||||
advance = thisTime - startTime;
|
||||
if ( advance < interval) {
|
||||
return;
|
||||
@@ -155,7 +155,7 @@ bool GlobalTimer::Update()
|
||||
|
||||
UpdateAnimations();
|
||||
|
||||
GetTime( thisTime );
|
||||
thisTime = GetTickCount();
|
||||
|
||||
if (!startTime) {
|
||||
startTime = thisTime;
|
||||
@@ -265,7 +265,7 @@ void GlobalTimer::AddAnimation(ControlAnimation* ctlanim, unsigned long time)
|
||||
AnimationRef* anim;
|
||||
unsigned long thisTime;
|
||||
|
||||
GetTime( thisTime );
|
||||
thisTime = GetTickCount();
|
||||
time += thisTime;
|
||||
|
||||
// if there are no free animation reference objects,
|
||||
@@ -309,7 +309,7 @@ void GlobalTimer::RemoveAnimation(ControlAnimation* ctlanim)
|
||||
void GlobalTimer::UpdateAnimations()
|
||||
{
|
||||
unsigned long thisTime;
|
||||
GetTime( thisTime );
|
||||
thisTime = GetTickCount();
|
||||
while (animations.begin() + first_animation != animations.end()) {
|
||||
AnimationRef* anim = animations[first_animation];
|
||||
if (anim->ctlanim == NULL) {
|
||||
|
||||
@@ -42,8 +42,8 @@ Bitmap* ImageMgr::GetBitmap()
|
||||
unsigned int width = GetWidth();
|
||||
Bitmap *data = new Bitmap(width, height);
|
||||
|
||||
printMessage("ImageMgr", "Don't know how to handle 24bit bitmap from ", WHITE);
|
||||
printf( "%s...", str->filename );
|
||||
printMessage("ImageMgr", "Don't know how to handle 24bit bitmap from %s...", WHITE,
|
||||
str->filename );
|
||||
printStatus( "ERROR", LIGHT_RED );
|
||||
|
||||
Sprite2D *spr = GetSprite2D();
|
||||
@@ -80,8 +80,8 @@ Image* ImageMgr::GetImage()
|
||||
|
||||
void ImageMgr::GetPalette(int /*colors*/, Color* /*pal*/)
|
||||
{
|
||||
printMessage("ImageMgr", "Can't get non-existant palette from ", WHITE);
|
||||
printf("%s... ", str->filename);
|
||||
printMessage("ImageMgr", "Can't get non-existant palette from %s... ", WHITE,
|
||||
str->filename);
|
||||
printStatus("ERROR", LIGHT_RED);
|
||||
}
|
||||
|
||||
|
||||
29
project/jni/application/gemrb/gemrb/core/IndexedArchive.cpp
Normal file
29
project/jni/application/gemrb/gemrb/core/IndexedArchive.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "IndexedArchive.h"
|
||||
|
||||
IndexedArchive::IndexedArchive(void)
|
||||
{
|
||||
}
|
||||
|
||||
IndexedArchive::~IndexedArchive(void)
|
||||
{
|
||||
}
|
||||
36
project/jni/application/gemrb/gemrb/core/IndexedArchive.h
Normal file
36
project/jni/application/gemrb/gemrb/core/IndexedArchive.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INDEXEDARCHIVE_H
|
||||
#define INDEXEDARCHIVE_H
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
class GEM_EXPORT IndexedArchive : public Plugin {
|
||||
public:
|
||||
IndexedArchive(void);
|
||||
virtual ~IndexedArchive(void);
|
||||
virtual int OpenArchive(const char* filename) = 0;
|
||||
virtual DataStream* GetStream(unsigned long Resource, unsigned long Type) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -25,10 +25,12 @@
|
||||
|
||||
#include "win32def.h"
|
||||
|
||||
#include "CharAnimations.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "Interface.h"
|
||||
#include "Map.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "GameScript/GSUtils.h"
|
||||
#include "GameScript/Matching.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
@@ -58,7 +60,7 @@ IniSpawn::~IniSpawn()
|
||||
}
|
||||
}
|
||||
|
||||
Holder<DataFileMgr> GetIniFile(const ieResRef DefaultArea)
|
||||
static Holder<DataFileMgr> GetIniFile(const ieResRef DefaultArea)
|
||||
{
|
||||
//the lack of spawn ini files is not a serious problem, happens all the time
|
||||
if (!gamedata->Exists( DefaultArea, IE_INI_CLASS_ID)) {
|
||||
@@ -76,13 +78,13 @@ Holder<DataFileMgr> GetIniFile(const ieResRef DefaultArea)
|
||||
}
|
||||
|
||||
PluginHolder<DataFileMgr> ini(IE_INI_CLASS_ID);
|
||||
ini->Open(inifile, true ); //autofree
|
||||
ini->Open(inifile);
|
||||
return ini;
|
||||
}
|
||||
|
||||
/*** initializations ***/
|
||||
|
||||
inline int CountElements(const char *s, char separator)
|
||||
static inline int CountElements(const char *s, char separator)
|
||||
{
|
||||
int ret = 1;
|
||||
while(*s) {
|
||||
@@ -92,7 +94,7 @@ inline int CountElements(const char *s, char separator)
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline void GetElements(const char *s, ieResRef *storage, int count)
|
||||
static inline void GetElements(const char *s, ieResRef *storage, int count)
|
||||
{
|
||||
while(count--) {
|
||||
ieResRef *field = storage+count;
|
||||
@@ -110,7 +112,7 @@ inline void GetElements(const char *s, ieResRef *storage, int count)
|
||||
}
|
||||
}
|
||||
|
||||
inline void GetElements(const char *s, ieVariable *storage, int count)
|
||||
static inline void GetElements(const char *s, ieVariable *storage, int count)
|
||||
{
|
||||
while(count--) {
|
||||
ieVariable *field = storage+count;
|
||||
@@ -205,8 +207,7 @@ void IniSpawn::ReadCreature(DataFileMgr *inifile, const char *crittername, Critt
|
||||
critter.CreFile=new ieResRef[critter.creaturecount];
|
||||
GetElements(s, critter.CreFile, critter.creaturecount);
|
||||
} else {
|
||||
printMessage( "IniSpawn"," ", LIGHT_RED);
|
||||
printf("Invalid spawn entry: %s\n", crittername);
|
||||
printMessage("IniSpawn", "Invalid spawn entry: %s\n", LIGHT_RED, crittername);
|
||||
}
|
||||
|
||||
s = inifile->GetKeyAsString(crittername,"point_select",NULL);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,19 +26,16 @@
|
||||
#ifndef INTERFACE_H
|
||||
#define INTERFACE_H
|
||||
|
||||
//skip messy warnings in MSVC6
|
||||
#include "win32def.h"
|
||||
|
||||
#include "SClassID.h"
|
||||
#include "exports.h"
|
||||
|
||||
#include "Cache.h"
|
||||
#include "Callback.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "Holder.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _MSC_VER // No SFINAE
|
||||
#include "Audio.h"
|
||||
@@ -49,6 +46,7 @@
|
||||
#include "StringMgr.h"
|
||||
#include "SymbolMgr.h"
|
||||
#include "Video.h"
|
||||
#include "WindowMgr.h"
|
||||
#endif
|
||||
|
||||
class Actor;
|
||||
@@ -67,9 +65,11 @@ class Factory;
|
||||
class Font;
|
||||
class Game;
|
||||
class GameControl;
|
||||
class GlobalTimer;
|
||||
class ITMExtHeader;
|
||||
class Image;
|
||||
class Item;
|
||||
class KeyMap;
|
||||
class Label;
|
||||
class Map;
|
||||
class MusicMgr;
|
||||
@@ -82,6 +82,7 @@ class SaveGameIterator;
|
||||
class ScriptEngine;
|
||||
class ScriptedAnimation;
|
||||
class Spell;
|
||||
class Sprite2D;
|
||||
class Store;
|
||||
class StringMgr;
|
||||
class SymbolMgr;
|
||||
@@ -349,6 +350,7 @@ private:
|
||||
EventHandler TickHook;
|
||||
int SpecialSpellsCount;
|
||||
SpellDescType *SpecialSpells;
|
||||
KeyMap *keymap;
|
||||
public:
|
||||
Holder<StringMgr> strings;
|
||||
GlobalTimer * timer;
|
||||
@@ -432,8 +434,6 @@ public:
|
||||
int GetControl(unsigned short WindowIndex, unsigned long ControlID) const;
|
||||
/** Adjust the scrolling of the control (if applicable) */
|
||||
int AdjustScrolling(unsigned short WindowIndex, unsigned short ControlIndex, short x, short y);
|
||||
/** Set the Text of a Control */
|
||||
int SetText(unsigned short WindowIndex, unsigned short ControlIndex, const char * string);
|
||||
/** Set the Tooltip text of a Control */
|
||||
int SetTooltip(unsigned short WindowIndex, unsigned short ControlIndex, const char * string);
|
||||
/** sets tooltip to be displayed */
|
||||
@@ -524,6 +524,12 @@ public:
|
||||
return calendar;
|
||||
}
|
||||
|
||||
/** Gets the KeyMap class */
|
||||
KeyMap * GetKeyMap() const
|
||||
{
|
||||
return keymap;
|
||||
}
|
||||
|
||||
/** Gets the WorldMap class, returns the current worldmap or the first worldmap containing the area*/
|
||||
WorldMap * GetWorldMap(const char *area = NULL);
|
||||
void SetWindowFrame(int i, Sprite2D *Picture);
|
||||
@@ -587,7 +593,7 @@ public:
|
||||
int CloseCurrentContainer();
|
||||
void SetCurrentContainer(Actor *actor, Container *arg, bool flag=false);
|
||||
Store *GetCurrentStore();
|
||||
int CloseCurrentStore();
|
||||
void CloseCurrentStore();
|
||||
Store *SetCurrentStore(const ieResRef resname, ieDword owner);
|
||||
void SetMouseScrollSpeed(int speed);
|
||||
int GetMouseScrollSpeed();
|
||||
@@ -601,7 +607,6 @@ public:
|
||||
void FreeITMExt(ITMExtHeader *p, Effect *e);
|
||||
void FreeSPLExt(SPLExtHeader *p, Effect *e);
|
||||
WorldMapArray *NewWorldMapArray(int count);
|
||||
void DoTheStoreHack(Store *s);
|
||||
/** plays stock gui sound referenced by index */
|
||||
void PlaySound(int idx);
|
||||
/** returns the first selected PC, if forced is set, then it returns
|
||||
@@ -745,7 +750,7 @@ public:
|
||||
unsigned int TooltipDelay;
|
||||
int IgnoreOriginalINI;
|
||||
unsigned int FogOfWar;
|
||||
bool CaseSensitive, GameOnCD, SkipIntroVideos, DrawFPS;
|
||||
bool CaseSensitive, GameOnCD, SkipIntroVideos, DrawFPS, TouchScrollAreas;
|
||||
bool GUIEnhancements;
|
||||
bool KeepCache;
|
||||
Variables *plugin_flags;
|
||||
@@ -754,7 +759,7 @@ public:
|
||||
/** returns true if the game is paused */
|
||||
bool IsFreezed();
|
||||
/** Draws the Visible windows in the Windows Array */
|
||||
void DrawWindows(void);
|
||||
void DrawWindows(bool allow_delete = false);
|
||||
/** Sends a termination signal to the Video Driver */
|
||||
bool Quit(void);
|
||||
/** CheatKey support */
|
||||
@@ -794,7 +799,6 @@ public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
int FileStreamPtrCount;
|
||||
int CachedFileStreamPtrCount;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -26,11 +26,13 @@
|
||||
#include "win32def.h"
|
||||
#include "strrefs.h"
|
||||
|
||||
#include "CharAnimations.h"
|
||||
#include "DisplayMessage.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "Interface.h"
|
||||
#include "Item.h"
|
||||
#include "Map.h"
|
||||
#include "ScriptEngine.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
|
||||
@@ -55,9 +57,7 @@ static int MagicBit = 0;
|
||||
|
||||
static void InvalidSlot(int slot)
|
||||
{
|
||||
printMessage("Inventory"," ",LIGHT_RED);
|
||||
printf("Invalid slot: %d!\n",slot);
|
||||
abort();
|
||||
error("Inventory", "Invalid slot: %d!\n", slot);
|
||||
}
|
||||
|
||||
//This inline function returns both an item pointer and the slot data.
|
||||
@@ -154,7 +154,7 @@ CREItem *Inventory::GetItem(unsigned int slot)
|
||||
|
||||
//This hack sets the charge counters for non-rechargeable items,
|
||||
//if their charge is zero
|
||||
inline void HackCharges(CREItem *item)
|
||||
static inline void HackCharges(CREItem *item)
|
||||
{
|
||||
Item *itm = gamedata->GetItem( item->ItemResRef );
|
||||
if (itm) {
|
||||
@@ -228,24 +228,24 @@ void Inventory::CalculateWeight()
|
||||
}
|
||||
|
||||
//if item is stacked mark it as so
|
||||
if (itm->StackAmount) {
|
||||
if (itm->MaxStackAmount) {
|
||||
slot->Flags |= IE_INV_ITEM_STACKED;
|
||||
}
|
||||
|
||||
slot->Weight = itm->Weight;
|
||||
slot->StackAmount = itm->StackAmount;
|
||||
slot->MaxStackAmount = itm->MaxStackAmount;
|
||||
gamedata->FreeItem( itm, slot->ItemResRef, false );
|
||||
}
|
||||
else {
|
||||
printMessage( "Inventory", " ", LIGHT_RED);
|
||||
printf("Invalid item: %s!\n", slot->ItemResRef);
|
||||
printMessage("Inventory", "Invalid item: %s!\n", LIGHT_RED,
|
||||
slot->ItemResRef);
|
||||
slot->Weight = 0;
|
||||
}
|
||||
} else {
|
||||
slot->Flags &= ~IE_INV_ITEM_ACQUIRED;
|
||||
}
|
||||
if (slot->Weight > 0) {
|
||||
Weight += slot->Weight * ((slot->Usages[0] && slot->StackAmount > 1) ? slot->Usages[0] : 1);
|
||||
Weight += slot->Weight * ((slot->Usages[0] && slot->MaxStackAmount > 1) ? slot->Usages[0] : 1);
|
||||
}
|
||||
}
|
||||
Changed = false;
|
||||
@@ -303,7 +303,7 @@ void Inventory::SetInventoryType(int arg)
|
||||
void Inventory::SetSlotCount(unsigned int size)
|
||||
{
|
||||
if (Slots.size()) {
|
||||
printf("Inventory size changed???\n");
|
||||
print("Inventory size changed???\n");
|
||||
//we don't allow reassignment,
|
||||
//if you want this, delete the previous Slots here
|
||||
abort();
|
||||
@@ -350,7 +350,7 @@ int Inventory::CountItems(const char *resref, bool stacks) const
|
||||
continue;
|
||||
}
|
||||
if (resref && resref[0]) {
|
||||
if (!strnicmp(resref, item->ItemResRef, 8) )
|
||||
if (strnicmp(resref, item->ItemResRef, 8) )
|
||||
continue;
|
||||
}
|
||||
if (stacks && (item->Flags&IE_INV_ITEM_STACKED) ) {
|
||||
@@ -638,17 +638,16 @@ int Inventory::AddSlotItem(CREItem* item, int slot, int slottype)
|
||||
}
|
||||
|
||||
CREItem *myslot = Slots[slot];
|
||||
if (ItemsAreCompatible( myslot, item )) {
|
||||
if (myslot->MaxStackAmount > 1 && ItemsAreCompatible(myslot, item)) {
|
||||
//calculate with the max movable stock
|
||||
int chunk = item->Usages[0];
|
||||
int newamount = myslot->Usages[0]+chunk;
|
||||
if (newamount>myslot->StackAmount) {
|
||||
newamount=myslot->StackAmount;
|
||||
chunk = item->Usages[0]-newamount;
|
||||
if (myslot->Usages[0] + chunk > myslot->MaxStackAmount) {
|
||||
chunk = myslot->MaxStackAmount - myslot->Usages[0];
|
||||
}
|
||||
if (!chunk) {
|
||||
return -1;
|
||||
return ASI_FAILED;
|
||||
}
|
||||
assert(chunk > 0);
|
||||
myslot->Flags |= IE_INV_ITEM_ACQUIRED;
|
||||
myslot->Usages[0] = (ieWord) (myslot->Usages[0] + chunk);
|
||||
item->Usages[0] = (ieWord) (item->Usages[0] - chunk);
|
||||
@@ -745,6 +744,7 @@ int Inventory::AddStoreItem(STOItem* item, int action)
|
||||
}
|
||||
item->PurchasedAmount--;
|
||||
}
|
||||
CalculateWeight();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -970,7 +970,7 @@ bool Inventory::EquipItem(unsigned int slot)
|
||||
int effect = core->QuerySlotEffects( slot );
|
||||
Item *itm = gamedata->GetItem(item->ItemResRef);
|
||||
if (!itm) {
|
||||
printf("Invalid item Equipped: %s Slot: %d\n", item->ItemResRef, slot);
|
||||
print("Invalid item Equipped: %s Slot: %d\n", item->ItemResRef, slot);
|
||||
return false;
|
||||
}
|
||||
switch (effect) {
|
||||
@@ -1381,7 +1381,7 @@ int Inventory::FindCandidateSlot(int slottype, size_t first_slot, const char *re
|
||||
}
|
||||
// check if the item fits in this slot, we use the cached
|
||||
// stackamount value
|
||||
if (item->Usages[0]<item->StackAmount) {
|
||||
if (item->Usages[0]<item->MaxStackAmount) {
|
||||
return (int) i;
|
||||
}
|
||||
}
|
||||
@@ -1398,7 +1398,7 @@ void Inventory::AddSlotItemRes(const ieResRef ItemResRef, int SlotID, int Charge
|
||||
TmpItem->Usages[1]=(ieWord) Charge1;
|
||||
TmpItem->Usages[2]=(ieWord) Charge2;
|
||||
TmpItem->Flags=0;
|
||||
if (core->ResolveRandomItem(TmpItem) && gamedata->Exists(TmpItem->ItemResRef, IE_ITM_CLASS_ID)) {
|
||||
if (core->ResolveRandomItem(TmpItem)) {
|
||||
AddSlotItem( TmpItem, SlotID );
|
||||
} else {
|
||||
delete TmpItem;
|
||||
@@ -1416,7 +1416,7 @@ void Inventory::SetSlotItemRes(const ieResRef ItemResRef, int SlotID, int Charge
|
||||
TmpItem->Usages[1]=(ieWord) Charge1;
|
||||
TmpItem->Usages[2]=(ieWord) Charge2;
|
||||
TmpItem->Flags=0;
|
||||
if (core->ResolveRandomItem(TmpItem) && gamedata->Exists(TmpItem->ItemResRef, IE_ITM_CLASS_ID)) {
|
||||
if (core->ResolveRandomItem(TmpItem)) {
|
||||
SetSlotItem( TmpItem, SlotID );
|
||||
} else {
|
||||
delete TmpItem;
|
||||
@@ -1448,7 +1448,7 @@ void Inventory::BreakItemSlot(ieDword slot)
|
||||
|
||||
void Inventory::dump()
|
||||
{
|
||||
printf( "INVENTORY:\n" );
|
||||
print( "INVENTORY:\n" );
|
||||
for (unsigned int i = 0; i < Slots.size(); i++) {
|
||||
CREItem* itm = Slots[i];
|
||||
|
||||
@@ -1456,13 +1456,13 @@ void Inventory::dump()
|
||||
continue;
|
||||
}
|
||||
|
||||
printf ( "%2u: %8.8s - (%d %d %d) Fl:0x%x Wt: %d x %dLb\n", i, itm->ItemResRef, itm->Usages[0], itm->Usages[1], itm->Usages[2], itm->Flags, itm->StackAmount, itm->Weight );
|
||||
print ( "%2u: %8.8s - (%d %d %d) Fl:0x%x Wt: %d x %dLb\n", i, itm->ItemResRef, itm->Usages[0], itm->Usages[1], itm->Usages[2], itm->Flags, itm->MaxStackAmount, itm->Weight );
|
||||
}
|
||||
|
||||
printf( "Equipped: %d\n", Equipped );
|
||||
print( "Equipped: %d\n", Equipped );
|
||||
Changed = true;
|
||||
CalculateWeight();
|
||||
printf( "Total weight: %d\n", Weight );
|
||||
print( "Total weight: %d\n", Weight );
|
||||
}
|
||||
|
||||
void Inventory::EquipBestWeapon(int flags)
|
||||
@@ -1795,7 +1795,7 @@ void Inventory::ChargeAllItems(int hours)
|
||||
}
|
||||
}
|
||||
|
||||
#define ITM_STEALING (IE_INV_ITEM_UNSTEALABLE | IE_INV_ITEM_MOVABLE | IE_INV_ITEM_EQUIPPED)
|
||||
#define ITM_STEALING (IE_INV_ITEM_UNSTEALABLE | IE_INV_ITEM_MOVABLE | IE_INV_ITEM_EQUIPPED) //0x442
|
||||
unsigned int Inventory::FindStealableItem()
|
||||
{
|
||||
unsigned int slot;
|
||||
@@ -1804,7 +1804,7 @@ unsigned int Inventory::FindStealableItem()
|
||||
slot = core->Roll(1, Slots.size(),-1);
|
||||
inc = slot&1?1:-1;
|
||||
|
||||
printf("Start Slot: %d, increment: %d\n", slot, inc);
|
||||
print("Start Slot: %d, increment: %d\n", slot, inc);
|
||||
//as the unsigned value underflows, it will be greater than Slots.size()
|
||||
for(;slot<Slots.size(); slot+=inc) {
|
||||
CREItem *item = Slots[slot];
|
||||
|
||||
@@ -170,15 +170,15 @@ public:
|
||||
ieWord Usages[CHARGE_COUNTERS];
|
||||
ieDword Flags;
|
||||
// 2 cached values from associated item. LEAVE IT SIGNED!
|
||||
/** Weight of items in the stack */
|
||||
/** Weight of each item in the stack */
|
||||
int Weight;
|
||||
/** Amount of items in this stack */
|
||||
int StackAmount;
|
||||
/** Maximum amount of items in this stack */
|
||||
int MaxStackAmount;
|
||||
|
||||
CREItem()
|
||||
{
|
||||
Weight=-1; //invalid weight
|
||||
StackAmount=0;
|
||||
MaxStackAmount=0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -342,7 +342,7 @@ private:
|
||||
int FindRangedProjectile(unsigned int type) const;
|
||||
// called by KillSlot
|
||||
void RemoveSlotEffects( /*CREItem* slot*/ ieDword slot );
|
||||
void KillSlot(ieDword index);
|
||||
void KillSlot(unsigned int index);
|
||||
inline Item *GetItemPointer(ieDword slot, CREItem *&Slot) const;
|
||||
void UpdateWeaponAnimation();
|
||||
void UpdateShieldAnimation(Item *it);
|
||||
|
||||
@@ -240,8 +240,8 @@ unsigned int Item::GetCastingDistance(int idx) const
|
||||
{
|
||||
ITMExtHeader *seh = GetExtHeader(idx);
|
||||
if (!seh) {
|
||||
printMessage("Item", "Cannot retrieve item header!!! ",RED);
|
||||
printf("required header: %d, maximum: %d\n", idx, (int) ExtHeaderCount);
|
||||
printMessage("Item", "Cannot retrieve item header!!! required header: %d, maximum: %d\n", RED,
|
||||
idx, (int) ExtHeaderCount);
|
||||
return 0;
|
||||
}
|
||||
return (unsigned int) seh->Range;
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
ieByte unknown3;
|
||||
ieDword KitUsability;
|
||||
ieDword Price;
|
||||
ieWord StackAmount;
|
||||
ieWord MaxStackAmount;
|
||||
ieResRef ItemIcon;
|
||||
ieWord LoreToID;
|
||||
ieResRef GroundIcon;
|
||||
|
||||
@@ -41,7 +41,7 @@ class GEM_EXPORT ItemMgr : public Plugin {
|
||||
public:
|
||||
ItemMgr(void);
|
||||
virtual ~ItemMgr(void);
|
||||
virtual bool Open(DataStream* stream, bool autoFree = true) = 0;
|
||||
virtual bool Open(DataStream* stream) = 0;
|
||||
virtual Item* GetItem(Item *s) = 0;
|
||||
};
|
||||
|
||||
|
||||
157
project/jni/application/gemrb/gemrb/core/KeyMap.cpp
Normal file
157
project/jni/application/gemrb/gemrb/core/KeyMap.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "KeyMap.h"
|
||||
#include "win32def.h"
|
||||
#include "Interface.h"
|
||||
#include "TableMgr.h"
|
||||
#include "ScriptEngine.h"
|
||||
#include "System/FileStream.h"
|
||||
|
||||
#define KEYLENGTH 64
|
||||
|
||||
Function::Function(const char *m, const char *f, int g)
|
||||
{
|
||||
strncpy(module, m, sizeof(module));
|
||||
strncpy(function, f, sizeof(function));
|
||||
group = g;
|
||||
}
|
||||
|
||||
KeyMap::KeyMap()
|
||||
{
|
||||
keymap.SetType(GEM_VARIABLES_POINTER);
|
||||
}
|
||||
|
||||
void ReleaseFunction(void *fun)
|
||||
{
|
||||
delete (Function *) fun;
|
||||
}
|
||||
|
||||
KeyMap::~KeyMap()
|
||||
{
|
||||
keymap.RemoveAll(ReleaseFunction);
|
||||
}
|
||||
|
||||
bool KeyMap::InitializeKeyMap(const char *inifile, const char *tablefile)
|
||||
{
|
||||
AutoTable kmtable(tablefile);
|
||||
|
||||
if (!kmtable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char tINIkeymap[_MAX_PATH];
|
||||
PathJoin( tINIkeymap, core->GamePath, inifile, NULL );
|
||||
FileStream* config = FileStream::OpenFile( tINIkeymap );
|
||||
|
||||
if (config == NULL) {
|
||||
printMessage("KeyMap","There is no '%s' file...\n", YELLOW, inifile);
|
||||
return false;
|
||||
}
|
||||
char name[KEYLENGTH+1], value[_MAX_PATH + 3];
|
||||
while (config->Remains()) {
|
||||
char line[_MAX_PATH];
|
||||
|
||||
if (config->ReadLine(line, _MAX_PATH) == -1)
|
||||
break;
|
||||
|
||||
if ((line[0] == '#') ||
|
||||
( line[0] == '[' ) ||
|
||||
( line[0] == '\r' ) ||
|
||||
( line[0] == '\n' ) ||
|
||||
( line[0] == ';' )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
name[0] = 0;
|
||||
value[0] = 0;
|
||||
|
||||
//ignore possible space after the =, sadly we cannot do the same with
|
||||
//spaces before it
|
||||
if (sscanf( line, "%[^=]= %[^\r\n]", name, value )!=2)
|
||||
continue;
|
||||
|
||||
strnlwrcpy(name,name,KEYLENGTH);
|
||||
//remove trailing spaces (bg1 ini file contains them)
|
||||
char *nameend = name + strlen( name ) - 1;
|
||||
while (nameend >= name && strchr( " \t\r\n", *nameend )) {
|
||||
*nameend-- = '\0';
|
||||
}
|
||||
|
||||
//change internal spaces to underscore
|
||||
for(int c=0;c<KEYLENGTH;c++) if (name[c]==' ') name[c]='_';
|
||||
|
||||
int l = strlen(value);
|
||||
Function *fun;
|
||||
void *tmp;
|
||||
|
||||
if (l<0 || l>1 || keymap.Lookup(value, tmp) ) {
|
||||
print("Ignoring key %s\n", value);
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *module;
|
||||
const char *function;
|
||||
const char *group;
|
||||
|
||||
if (kmtable->GetRowIndex(name)>=0 ) {
|
||||
module = kmtable->QueryField(name, "MODULE");
|
||||
function = kmtable->QueryField(name, "FUNCTION");
|
||||
group = kmtable->QueryField(name, "GROUP");
|
||||
} else {
|
||||
module = kmtable->QueryField("Default","MODULE");
|
||||
function = kmtable->QueryField("Default","FUNCTION");
|
||||
group = kmtable->QueryField("Default","GROUP");
|
||||
}
|
||||
fun = new Function(module, function, atoi(group));
|
||||
keymap.SetAt(value, fun);
|
||||
print("Adding key %s with function %s::%s\n", value, module, function);
|
||||
}
|
||||
delete config;
|
||||
return true;
|
||||
}
|
||||
|
||||
//group can be:
|
||||
//main gamecontrol
|
||||
void KeyMap::ResolveKey(int key, int group)
|
||||
{
|
||||
Function *fun;
|
||||
void *tmp;
|
||||
char keystr[2];
|
||||
|
||||
keystr[0]=(char) key;
|
||||
keystr[1]=0;
|
||||
|
||||
print("Looking up key: %c (%s) \n", key, keystr);
|
||||
|
||||
if (!keymap.Lookup(keystr, tmp) ) {
|
||||
return;
|
||||
}
|
||||
fun = (Function *) tmp;
|
||||
|
||||
if (fun->group!=group) {
|
||||
return;
|
||||
}
|
||||
|
||||
printMessage("KeyMap", " ", WHITE);
|
||||
print("RunFunction(%s::%s)\n",fun->module, fun->function);
|
||||
core->GetGUIScriptEngine()->RunFunction(fun->module, fun->function);
|
||||
}
|
||||
|
||||
48
project/jni/application/gemrb/gemrb/core/KeyMap.h
Normal file
48
project/jni/application/gemrb/gemrb/core/KeyMap.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef KEYMAP_H
|
||||
#define KEYMAP_H
|
||||
|
||||
#include "exports.h"
|
||||
#include "Variables.h"
|
||||
|
||||
class Variables;
|
||||
|
||||
class GEM_EXPORT KeyMap {
|
||||
private:
|
||||
Variables keymap;
|
||||
public:
|
||||
KeyMap();
|
||||
~KeyMap();
|
||||
bool InitializeKeyMap(const char *inifile, const char *keyfile);
|
||||
void ResolveKey(int key, int group);
|
||||
};
|
||||
|
||||
class Function {
|
||||
public:
|
||||
char module[16];
|
||||
char function[32];
|
||||
int group;
|
||||
|
||||
Function(const char *m, const char *f, int g);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -51,15 +51,18 @@ libgemrb_core_la_SOURCES = \
|
||||
GameScript/Objects.cpp \
|
||||
GameScript/Triggers.cpp \
|
||||
GlobalTimer.cpp \
|
||||
FileCache.cpp \
|
||||
Image.cpp \
|
||||
ImageFactory.cpp \
|
||||
ImageMgr.cpp \
|
||||
ImageWriter.cpp \
|
||||
IndexedArchive.cpp \
|
||||
IniSpawn.cpp \
|
||||
Interface.cpp \
|
||||
Inventory.cpp \
|
||||
Item.cpp \
|
||||
ItemMgr.cpp \
|
||||
KeyMap.cpp \
|
||||
LRUCache.cpp \
|
||||
Map.cpp \
|
||||
MapMgr.cpp \
|
||||
@@ -69,6 +72,7 @@ libgemrb_core_la_SOURCES = \
|
||||
PalettedImageMgr.cpp \
|
||||
Particles.cpp \
|
||||
Plugin.cpp \
|
||||
PluginLoader.cpp \
|
||||
PluginMgr.cpp \
|
||||
Polygon.cpp \
|
||||
Projectile.cpp \
|
||||
@@ -99,10 +103,12 @@ libgemrb_core_la_SOURCES = \
|
||||
StoreMgr.cpp \
|
||||
StringMgr.cpp \
|
||||
SymbolMgr.cpp \
|
||||
System/CachedFileStream.cpp \
|
||||
System/DataStream.cpp \
|
||||
System/FileStream.cpp \
|
||||
System/Logging.cpp \
|
||||
System/MemoryStream.cpp \
|
||||
System/SlicedStream.cpp \
|
||||
System/String.cpp \
|
||||
System/VFS.cpp \
|
||||
TableMgr.cpp \
|
||||
Tile.cpp \
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "DisplayMessage.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "IniSpawn.h"
|
||||
#include "Interface.h"
|
||||
#include "MapMgr.h"
|
||||
#include "MusicMgr.h"
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "Palette.h"
|
||||
#include "Particles.h"
|
||||
#include "PathFinder.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "Projectile.h"
|
||||
#include "ScriptedAnimation.h"
|
||||
#include "TileMap.h"
|
||||
@@ -45,6 +47,7 @@
|
||||
#include "strrefs.h"
|
||||
#include "GameScript/GSUtils.h"
|
||||
#include "GUI/GameControl.h"
|
||||
#include "GUI/Window.h"
|
||||
#include "Scriptable/Container.h"
|
||||
#include "Scriptable/Door.h"
|
||||
#include "Scriptable/InfoPoint.h"
|
||||
@@ -73,7 +76,7 @@ static int LargeFog;
|
||||
static TerrainSounds *terrainsounds=NULL;
|
||||
static int tsndcount = -1;
|
||||
|
||||
void ReleaseSpawnGroup(void *poi)
|
||||
static void ReleaseSpawnGroup(void *poi)
|
||||
{
|
||||
delete (SpawnGroup *) poi;
|
||||
}
|
||||
@@ -95,7 +98,7 @@ void Map::ReleaseMemory()
|
||||
}
|
||||
}
|
||||
|
||||
inline static AnimationObjectType SelectObject(Actor *actor, int q, AreaAnimation *a, ScriptedAnimation *sca, Particles *spark, Projectile *pro)
|
||||
static inline AnimationObjectType SelectObject(Actor *actor, int q, AreaAnimation *a, ScriptedAnimation *sca, Particles *spark, Projectile *pro)
|
||||
{
|
||||
int actorh;
|
||||
if (actor) {
|
||||
@@ -148,7 +151,7 @@ inline static AnimationObjectType SelectObject(Actor *actor, int q, AreaAnimatio
|
||||
|
||||
//returns true if creature must be embedded in the area
|
||||
//npcs in saved game shouldn't be embedded either
|
||||
inline static bool MustSave(Actor *actor)
|
||||
static inline bool MustSave(Actor *actor)
|
||||
{
|
||||
if (actor->Persistent()) {
|
||||
return false;
|
||||
@@ -159,7 +162,7 @@ inline static bool MustSave(Actor *actor)
|
||||
}
|
||||
|
||||
//Preload spawn group entries (creature resrefs that reference groups of creatures)
|
||||
void InitSpawnGroups()
|
||||
static void InitSpawnGroups()
|
||||
{
|
||||
ieResRef GroupName;
|
||||
int i;
|
||||
@@ -193,7 +196,7 @@ void InitSpawnGroups()
|
||||
}
|
||||
|
||||
//Preload the searchmap configuration
|
||||
void InitPathFinder()
|
||||
static void InitPathFinder()
|
||||
{
|
||||
PathFinderInited = true;
|
||||
tsndcount = 0;
|
||||
@@ -229,7 +232,7 @@ void InitPathFinder()
|
||||
}
|
||||
}
|
||||
|
||||
void AddLOS(int destx, int desty, int slot)
|
||||
static void AddLOS(int destx, int desty, int slot)
|
||||
{
|
||||
for (int i=0;i<MaxVisibility;i++) {
|
||||
int x = ((destx*i + MaxVisibility/2) / MaxVisibility) * 16;
|
||||
@@ -243,7 +246,7 @@ void AddLOS(int destx, int desty, int slot)
|
||||
}
|
||||
}
|
||||
|
||||
void InitExplore()
|
||||
static void InitExplore()
|
||||
{
|
||||
LargeFog = !core->HasFeature(GF_SMALL_FOG);
|
||||
|
||||
@@ -466,8 +469,7 @@ void Map::MoveToNewArea(const char *area, const char *entrance, unsigned int dir
|
||||
}
|
||||
Map* map = game->GetMap(area, false);
|
||||
if (!map) {
|
||||
printMessage("Map", " ", LIGHT_RED);
|
||||
printf("Invalid map: %s\n",area);
|
||||
printMessage("Map", "Invalid map: %s\n", LIGHT_RED, area);
|
||||
command[0]=0;
|
||||
return;
|
||||
}
|
||||
@@ -494,8 +496,8 @@ void Map::MoveToNewArea(const char *area, const char *entrance, unsigned int dir
|
||||
Y = map->TMap->YCellCount * 32;
|
||||
} else {
|
||||
// crashes in original engine
|
||||
printMessage("Map", " ", YELLOW);
|
||||
printf( "WARNING!!! EntryPoint '%s' does not exist and direction %d is invalid\n", entrance, direction );
|
||||
printMessage("Map", "WARNING!!! EntryPoint '%s' does not exist and direction %d is invalid\n", YELLOW,
|
||||
entrance, direction);
|
||||
X = map->TMap->XCellCount * 64;
|
||||
Y = map->TMap->YCellCount * 64;
|
||||
}
|
||||
@@ -516,7 +518,7 @@ void Map::MoveToNewArea(const char *area, const char *entrance, unsigned int dir
|
||||
pc->ClearPath();
|
||||
pc->ClearActions();
|
||||
pc->AddAction( GenerateAction( command ) );
|
||||
pc->ProcessActions(true);
|
||||
pc->ProcessActions();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -534,7 +536,7 @@ void Map::MoveToNewArea(const char *area, const char *entrance, unsigned int dir
|
||||
pc->ClearPath();
|
||||
pc->ClearActions();
|
||||
pc->AddAction( GenerateAction( command ) );
|
||||
pc->ProcessActions(true);
|
||||
pc->ProcessActions();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -543,7 +545,7 @@ void Map::MoveToNewArea(const char *area, const char *entrance, unsigned int dir
|
||||
actor->ClearPath();
|
||||
actor->ClearActions();
|
||||
actor->AddAction( GenerateAction( command ) );
|
||||
actor->ProcessActions(true);
|
||||
actor->ProcessActions();
|
||||
}
|
||||
|
||||
void Map::UseExit(Actor *actor, InfoPoint *ip)
|
||||
@@ -572,9 +574,10 @@ void Map::UseExit(Actor *actor, InfoPoint *ip)
|
||||
return;
|
||||
}
|
||||
if (ip->Scripts[0]) {
|
||||
ip->LastTriggerObject = ip->LastTrigger = ip->LastEntered = actor->GetGlobalID();
|
||||
ip->AddTrigger(TriggerEntry(trigger_entered, actor->GetGlobalID()));
|
||||
// FIXME
|
||||
ip->ExecuteScript( 1 );
|
||||
ip->ProcessActions(true);
|
||||
ip->ProcessActions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,19 +629,20 @@ void Map::UpdateScripts()
|
||||
}
|
||||
|
||||
// fuzzie added this check because some area scripts (eg, AR1600 when
|
||||
// escaping Brynnlaw) were executing after they were meant to be done,
|
||||
// escaping Brynnlaw) were executing after they were meant to be done,
|
||||
// and this seems the nicest way of handling that for now - it's quite
|
||||
// possibly wrong (so if you have problems, revert this and find
|
||||
// another way)
|
||||
if (has_pcs) {
|
||||
//Run all the Map Scripts (as in the original)
|
||||
//The default area script is in the last slot anyway
|
||||
ExecuteScript( MAX_SCRIPTS );
|
||||
//ExecuteScript( MAX_SCRIPTS );
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
//Execute Pending Actions
|
||||
//if it is only here, then the drawing will fail
|
||||
ProcessActions(false);
|
||||
ProcessActions();
|
||||
|
||||
// If scripts frozen, return.
|
||||
// This fixes starting a new IWD game. The above ProcessActions pauses the
|
||||
@@ -650,8 +654,11 @@ void Map::UpdateScripts()
|
||||
int q=Qcount[PR_SCRIPT];
|
||||
|
||||
Game *game = core->GetGame();
|
||||
bool timestop = game->IsTimestopActive();
|
||||
if (!timestop) {
|
||||
game->timestop_owner = NULL;
|
||||
}
|
||||
Actor *timestop_owner = game->timestop_owner;
|
||||
bool timestop = game->timestop_end>game->GameTime;
|
||||
|
||||
while (q--) {
|
||||
Actor* actor = queue[PR_SCRIPT][q];
|
||||
@@ -660,8 +667,9 @@ void Map::UpdateScripts()
|
||||
actor->no_more_steps = true;
|
||||
continue;
|
||||
}
|
||||
if (timestop && actor!=timestop_owner && actor->Modified[IE_DISABLETIMESTOP] ) {
|
||||
if (timestop && actor!=timestop_owner && actor->Modified[IE_DISABLETIMESTOP] == 0) {
|
||||
actor->no_more_steps = true;
|
||||
actor->ClearPath(); //HACK: prevents jumping when timestop ends
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -679,6 +687,9 @@ void Map::UpdateScripts()
|
||||
}
|
||||
}
|
||||
actor->no_more_steps = false;
|
||||
if (actor->Immobile()) {
|
||||
actor->ClearPath(); //HACK: prevents jumping when effect ends
|
||||
}
|
||||
|
||||
/*
|
||||
* we run scripts all at once because one of the actions in ProcessActions
|
||||
@@ -691,7 +702,7 @@ void Map::UpdateScripts()
|
||||
* point, etc), but i did it this way for now because it seems least painful
|
||||
* and we should probably be staggering the script executions anyway
|
||||
*/
|
||||
actor->ExecuteScript( MAX_SCRIPTS );
|
||||
actor->Update();
|
||||
|
||||
}
|
||||
|
||||
@@ -707,8 +718,6 @@ void Map::UpdateScripts()
|
||||
Actor* actor = queue[PR_SCRIPT][q];
|
||||
if (actor->no_more_steps) continue;
|
||||
|
||||
actor->ProcessActions(false);
|
||||
|
||||
actor->UpdateActorState(game->GameTime);
|
||||
|
||||
actor->inventory.CalculateWeight();
|
||||
@@ -731,7 +740,7 @@ void Map::UpdateScripts()
|
||||
} else if (avatar->WalkScale) {
|
||||
speed = avatar->WalkScale;
|
||||
} else {
|
||||
//printf("no walkscale for anim %d!\n", actor->BaseStats[IE_ANIMATION_ID]);
|
||||
//print("no walkscale for anim %d!\n", actor->BaseStats[IE_ANIMATION_ID]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -767,10 +776,7 @@ void Map::UpdateScripts()
|
||||
Door* door = TMap->GetDoor( doorCount++ );
|
||||
if (!door)
|
||||
break;
|
||||
if (door->Scripts[0])
|
||||
door->ExecuteScript( 1 );
|
||||
//Execute Pending Actions
|
||||
door->ProcessActions(false);
|
||||
door->Update();
|
||||
}
|
||||
|
||||
//Check if we need to start some container scripts
|
||||
@@ -779,10 +785,7 @@ void Map::UpdateScripts()
|
||||
Container* container = TMap->GetContainer( containerCount++ );
|
||||
if (!container)
|
||||
break;
|
||||
if (container->Scripts[0])
|
||||
container->ExecuteScript( 1 );
|
||||
//Execute Pending Actions
|
||||
container->ProcessActions(false);
|
||||
container->Update();
|
||||
}
|
||||
|
||||
//Check if we need to start some trap scripts
|
||||
@@ -799,15 +802,7 @@ void Map::UpdateScripts()
|
||||
|
||||
//If this InfoPoint is a Switch Trigger
|
||||
if (ip->Type == ST_TRIGGER) {
|
||||
//Check if this InfoPoint was activated
|
||||
if (ip->LastTrigger) {
|
||||
if (wasActive && ip->Scripts[0]) {
|
||||
//Run the InfoPoint script
|
||||
ip->ExecuteScript( 1 );
|
||||
}
|
||||
}
|
||||
//Execute Pending Actions
|
||||
ip->ProcessActions(false);
|
||||
ip->Update();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -844,14 +839,12 @@ void Map::UpdateScripts()
|
||||
}
|
||||
|
||||
if (wasActive) {
|
||||
ip->ExecuteScript( 1 );
|
||||
//Play the PST specific enter sound
|
||||
if (wasActive&TRAP_USEPOINT) {
|
||||
core->GetAudioDrv()->Play(ip->EnterWav, ip->TrapLaunch.x, ip->TrapLaunch.y);
|
||||
}
|
||||
ip->Update();
|
||||
}
|
||||
//Execute Pending Actions
|
||||
ip->ProcessActions(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -862,7 +855,7 @@ void Map::ResolveTerrainSound(ieResRef &sound, Point &Pos) {
|
||||
memcpy(sound, terrainsounds[i].Sounds[type], sizeof(ieResRef) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Map::DoStepForActor(Actor *actor, int speed, ieDword time) {
|
||||
@@ -1069,7 +1062,15 @@ void Map::DrawMap(Region screen)
|
||||
}
|
||||
|
||||
if (!bgoverride) {
|
||||
int rain;
|
||||
int rain, flags;
|
||||
|
||||
if (game->IsTimestopActive()) {
|
||||
flags = TILE_GREY;
|
||||
}
|
||||
else if (AreaFlags&AF_DREAM) {
|
||||
flags = TILE_SEPIA;
|
||||
} else flags = 0;
|
||||
|
||||
if (HasWeather()) {
|
||||
//zero when the weather particles are all gone
|
||||
rain = game->weather->GetPhase()-P_EMPTY;
|
||||
@@ -1077,13 +1078,12 @@ void Map::DrawMap(Region screen)
|
||||
rain = 0;
|
||||
}
|
||||
|
||||
TMap->DrawOverlays( screen, rain );
|
||||
TMap->DrawOverlays( screen, rain, flags );
|
||||
|
||||
//Draw Outlines
|
||||
DrawHighlightables( screen );
|
||||
}
|
||||
|
||||
Region vp = video->GetViewport();
|
||||
//if it is only here, then the scripting will fail?
|
||||
GenerateQueues();
|
||||
SortQueues();
|
||||
@@ -1261,11 +1261,10 @@ void Map::AddAnimation(AreaAnimation* panim)
|
||||
anim->InitAnimation();
|
||||
|
||||
aniIterator iter;
|
||||
|
||||
|
||||
int Height = anim->GetHeight();
|
||||
printf("Adding %s at height %d, Pos: %d.%d\n", anim->Name, Height, anim->Pos.x, anim->Pos.y);
|
||||
for(iter=animations.begin(); (iter!=animations.end()) && ((*iter)->GetHeight()<Height); iter++) ;
|
||||
animations.insert(iter, anim);
|
||||
animations.insert(iter, anim);
|
||||
}
|
||||
|
||||
//reapplying all of the effects on the actors of this map
|
||||
@@ -1290,9 +1289,10 @@ void Map::Shout(Actor* actor, int shoutID, unsigned int radius)
|
||||
}
|
||||
}
|
||||
if (shoutID) {
|
||||
listener->AddTrigger(TriggerEntry(trigger_heard, actor->GetGlobalID(), shoutID));
|
||||
listener->LastHeard = actor->GetGlobalID();
|
||||
listener->LastShout = shoutID;
|
||||
} else {
|
||||
listener->AddTrigger(TriggerEntry(trigger_help, actor->GetGlobalID()));
|
||||
listener->LastHelp = actor->GetGlobalID();
|
||||
}
|
||||
}
|
||||
@@ -2122,30 +2122,30 @@ void Map::DebugDump(bool show_actors) const
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf( "DebugDump of Area %s:\n", scriptName );
|
||||
printf ("Scripts:");
|
||||
print( "DebugDump of Area %s:\n", scriptName );
|
||||
print ("Scripts:");
|
||||
|
||||
for (i = 0; i < MAX_SCRIPTS; i++) {
|
||||
const char* poi = "<none>";
|
||||
if (Scripts[i]) {
|
||||
poi = Scripts[i]->GetName();
|
||||
}
|
||||
printf( " %.8s", poi );
|
||||
print( " %.8s", poi );
|
||||
}
|
||||
printf( "Area Global ID: %d\n", GetGlobalID());
|
||||
printf( "OutDoor: %s\n", YESNO(AreaType & AT_OUTDOOR ) );
|
||||
printf( "Day/Night: %s\n", YESNO(AreaType & AT_DAYNIGHT ) );
|
||||
printf( "Extended night: %s\n", YESNO(AreaType & AT_EXTENDED_NIGHT ) );
|
||||
printf( "Weather: %s\n", YESNO(AreaType & AT_WEATHER ) );
|
||||
printf( "Area Type: %d\n", AreaType & (AT_CITY|AT_FOREST|AT_DUNGEON) );
|
||||
printf( "Can rest: %s\n", YESNO(AreaType & AT_CAN_REST) );
|
||||
print( "Area Global ID: %d\n", GetGlobalID());
|
||||
print( "OutDoor: %s\n", YESNO(AreaType & AT_OUTDOOR ) );
|
||||
print( "Day/Night: %s\n", YESNO(AreaType & AT_DAYNIGHT ) );
|
||||
print( "Extended night: %s\n", YESNO(AreaType & AT_EXTENDED_NIGHT ) );
|
||||
print( "Weather: %s\n", YESNO(AreaType & AT_WEATHER ) );
|
||||
print( "Area Type: %d\n", AreaType & (AT_CITY|AT_FOREST|AT_DUNGEON) );
|
||||
print( "Can rest: %s\n", YESNO(AreaType & AT_CAN_REST) );
|
||||
|
||||
if (show_actors) {
|
||||
printf("\n");
|
||||
print("\n");
|
||||
i = actors.size();
|
||||
while (i--) {
|
||||
if (!(actors[i]->GetInternalFlag()&(IF_JUSTDIED|IF_REALLYDIED))) {
|
||||
printf("Actor: %s at %d.%d\n", actors[i]->GetName(1), actors[i]->Pos.x, actors[i]->Pos.y);
|
||||
print("Actor: %s at %d.%d\n", actors[i]->GetName(1), actors[i]->Pos.x, actors[i]->Pos.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2326,7 +2326,7 @@ PathNode* Map::RunAway(const Point &s, const Point &d, unsigned int size, unsign
|
||||
|
||||
unsigned int Cost = MapSet[y * Width + x] + NormalCost;
|
||||
if (Cost > PathLen) {
|
||||
//printf("Path not found!\n");
|
||||
//print("Path not found!\n");
|
||||
break;
|
||||
}
|
||||
SetupNode( x - 1, y - 1, size, Cost );
|
||||
@@ -2669,12 +2669,12 @@ PathNode* Map::FindPath(const Point &s, const Point &d, unsigned int size, int M
|
||||
|
||||
if (pos == pos2) {
|
||||
//We've found _a_ path
|
||||
//printf("GOAL!!!\n");
|
||||
//print("GOAL!!!\n");
|
||||
break;
|
||||
}
|
||||
unsigned int Cost = MapSet[y * Width + x] + NormalCost;
|
||||
if (Cost > 65500) {
|
||||
//printf("Path not found!\n");
|
||||
//print("Path not found!\n");
|
||||
break;
|
||||
}
|
||||
SetupNode( x - 1, y - 1, size, Cost );
|
||||
@@ -2828,8 +2828,8 @@ int Map::WhichEdge(const Point &s)
|
||||
unsigned int sX=s.x/16;
|
||||
unsigned int sY=s.y/12;
|
||||
if (!(GetBlocked( sX, sY )&PATH_MAP_TRAVEL)) {
|
||||
printMessage("Map"," ",YELLOW);
|
||||
printf("This isn't a travel region [%d.%d]?\n",sX, sY);
|
||||
printMessage("Map", "This isn't a travel region [%d.%d]?\n", YELLOW,
|
||||
sX, sY);
|
||||
return -1;
|
||||
}
|
||||
sX*=Height;
|
||||
@@ -3498,7 +3498,7 @@ Animation *AreaAnimation::GetAnimationPiece(AnimationFactory *af, int animCycle)
|
||||
if (!anim)
|
||||
anim = af->GetCycle( 0 );
|
||||
if (!anim) {
|
||||
printf("Cannot load animation: %s\n", BAM);
|
||||
print("Cannot load animation: %s\n", BAM);
|
||||
return NULL;
|
||||
}
|
||||
//this will make the animation stop when the game is stopped
|
||||
@@ -3520,7 +3520,7 @@ void AreaAnimation::InitAnimation()
|
||||
AnimationFactory* af = ( AnimationFactory* )
|
||||
gamedata->GetFactoryResource( BAM, IE_BAM_CLASS_ID );
|
||||
if (!af) {
|
||||
printf("Cannot load animation: %s\n", BAM);
|
||||
print("Cannot load animation: %s\n", BAM);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3664,15 +3664,20 @@ void Map::SeeSpellCast(Scriptable *caster, ieDword spell)
|
||||
return;
|
||||
}
|
||||
|
||||
LastCasterSeen = caster->GetGlobalID();
|
||||
LastSpellSeen = spell;
|
||||
// FIXME: this seems clearly wrong, but matches old gemrb behaviour
|
||||
unsigned short triggerType = trigger_spellcast;
|
||||
if (spell >= 3000)
|
||||
triggerType = trigger_spellcastinnate;
|
||||
else if (spell < 2000)
|
||||
triggerType = trigger_spellcastpriest;
|
||||
|
||||
caster->AddTrigger(TriggerEntry(triggerType, caster->GetGlobalID(), spell));
|
||||
|
||||
size_t i = actors.size();
|
||||
while (i--) {
|
||||
Actor* witness = actors[i];
|
||||
if (CanSee(witness, caster, true, 0)) {
|
||||
witness->LastSpellSeen=LastSpellSeen;
|
||||
witness->LastCasterSeen=LastCasterSeen;
|
||||
caster->AddTrigger(TriggerEntry(triggerType, caster->GetGlobalID(), spell));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,6 @@ class Map;
|
||||
#include "exports.h"
|
||||
#include "globals.h"
|
||||
|
||||
#include "Bitmap.h"
|
||||
#include "Image.h"
|
||||
#include "IniSpawn.h"
|
||||
#include "SpriteCover.h"
|
||||
#include "Scriptable/Scriptable.h"
|
||||
|
||||
#include <queue>
|
||||
@@ -38,11 +34,17 @@ class Actor;
|
||||
class Ambient;
|
||||
class Animation;
|
||||
class AnimationFactory;
|
||||
class Bitmap;
|
||||
class CREItem;
|
||||
class GameControl;
|
||||
class Image;
|
||||
class IniSpawn;
|
||||
class Palette;
|
||||
class Particles;
|
||||
struct PathNode;
|
||||
class Projectile;
|
||||
class ScriptedAnimation;
|
||||
class SpriteCover;
|
||||
class TileMap;
|
||||
class Wall_Polygon;
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
#ifndef MAPMGR_H
|
||||
#define MAPMGR_H
|
||||
|
||||
#include "Map.h"
|
||||
#include "Plugin.h"
|
||||
#include "Scriptable/Scriptable.h"
|
||||
#include "System/DataStream.h"
|
||||
|
||||
class DataStream;
|
||||
class Map;
|
||||
|
||||
/**
|
||||
* @class MapMgr
|
||||
@@ -41,7 +41,7 @@ class GEM_EXPORT MapMgr : public Plugin {
|
||||
public:
|
||||
MapMgr(void);
|
||||
virtual ~MapMgr(void);
|
||||
virtual bool Open(DataStream* stream, bool autoFree = true) = 0;
|
||||
virtual bool Open(DataStream* stream) = 0;
|
||||
virtual bool ChangeMap(Map *map, bool day_or_night) = 0;
|
||||
virtual Map* GetMap(const char* ResRef, bool day_or_night) = 0;
|
||||
|
||||
|
||||
@@ -46,6 +46,16 @@ void Palette::CreateShadedAlphaChannel()
|
||||
}
|
||||
alpha = true;
|
||||
}
|
||||
|
||||
void Palette::Brighten()
|
||||
{
|
||||
for (int i = 0; i<256;i++) {
|
||||
col[i].r = (col[i].r+256)/2;
|
||||
col[i].g = (col[i].g+256)/2;
|
||||
col[i].b = (col[i].b+256)/2;
|
||||
col[i].a = (col[i].a+256)/2;
|
||||
}
|
||||
}
|
||||
|
||||
Palette* Palette::Copy()
|
||||
{
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
}
|
||||
|
||||
void CreateShadedAlphaChannel();
|
||||
void Brighten();
|
||||
|
||||
void SetupPaperdollColours(const ieDword* Colors, unsigned int type);
|
||||
void SetupRGBModification(const Palette* src, const RGBModifier* mods,
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
|
||||
#include "Particles.h"
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Video.h"
|
||||
#include "CharAnimations.h"
|
||||
#include "Game.h"
|
||||
#include "Interface.h"
|
||||
#include "TableMgr.h"
|
||||
#include "Video.h"
|
||||
|
||||
Color sparkcolors[MAX_SPARK_COLOR][MAX_SPARK_PHASE];
|
||||
bool inited = false;
|
||||
@@ -31,7 +33,7 @@ bool inited = false;
|
||||
|
||||
static int spark_color_indices[SPARK_COUNT]={12,5,0,6,1,8,2,7,9,3,4,10,11};
|
||||
|
||||
void TranslateColor(const char *value, Color &color)
|
||||
static void TranslateColor(const char *value, Color &color)
|
||||
{
|
||||
int r = 0;
|
||||
int g = 0;
|
||||
@@ -50,7 +52,7 @@ void TranslateColor(const char *value, Color &color)
|
||||
color.b=b;
|
||||
}
|
||||
|
||||
void InitSparks()
|
||||
static void InitSparks()
|
||||
{
|
||||
int i,j;
|
||||
AutoTable tab("sprklclr");
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "exports.h"
|
||||
|
||||
#include "Holder.h"
|
||||
#include "PluginMgr.h"
|
||||
#include "TypeID.h"
|
||||
|
||||
#include <cstddef>
|
||||
@@ -47,19 +46,4 @@ public:
|
||||
virtual ~Plugin(void);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class PluginHolder : public Holder<T> {
|
||||
public:
|
||||
PluginHolder()
|
||||
{
|
||||
}
|
||||
PluginHolder(PluginID id)
|
||||
: Holder<T>(static_cast<T*>(PluginMgr::Get()->GetPlugin(id)))
|
||||
{
|
||||
}
|
||||
~PluginHolder()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
239
project/jni/application/gemrb/gemrb/core/PluginLoader.cpp
Normal file
239
project/jni/application/gemrb/gemrb/core/PluginLoader.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "PluginLoader.h"
|
||||
|
||||
#include "SClassID.h" // For PluginID
|
||||
#include "win32def.h"
|
||||
|
||||
#include "Variables.h"
|
||||
#include "Interface.h"
|
||||
#include "PluginMgr.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
typedef HMODULE LibHandle;
|
||||
#else
|
||||
typedef void *LibHandle;
|
||||
#endif
|
||||
|
||||
class PluginMgr;
|
||||
|
||||
struct PluginDesc {
|
||||
LibHandle handle;
|
||||
PluginID ID;
|
||||
const char *Description;
|
||||
bool (*Register)(PluginMgr*);
|
||||
};
|
||||
|
||||
typedef const char* (*Version_t)(void);
|
||||
typedef const char* (*Description_t)(void);
|
||||
typedef PluginID (*ID_t)();
|
||||
typedef bool (* Register_t)(PluginMgr*);
|
||||
|
||||
#ifdef HAVE_FORBIDDEN_OBJECT_TO_FUNCTION_CAST
|
||||
#include <assert.h>
|
||||
typedef void *(* voidvoid)(void);
|
||||
static inline voidvoid my_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
void *value = dlsym(handle,symbol);
|
||||
voidvoid ret;
|
||||
assert(sizeof(ret)==sizeof(value) );
|
||||
memcpy(&ret, &value, sizeof(ret) );
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#define my_dlsym dlsym
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define FREE_PLUGIN( handle ) FreeLibrary( handle )
|
||||
#define GET_PLUGIN_SYMBOL( handle, name ) GetProcAddress( handle, name )
|
||||
#define PRINT_DLERROR
|
||||
#else
|
||||
#define FREE_PLUGIN( handle ) dlclose( handle )
|
||||
#define GET_PLUGIN_SYMBOL( handle, name ) my_dlsym( handle, name )
|
||||
#define PRINT_DLERROR print( "%s\n", dlerror() )
|
||||
#endif
|
||||
|
||||
/** Return names of all *.so or *.dll files in the given directory */
|
||||
#ifdef WIN32
|
||||
static bool FindFiles( char* path, std::list<char*> &files )
|
||||
{
|
||||
//The windows _findfirst/_findnext functions allow the use of wildcards so we'll use them :)
|
||||
struct _finddata_t c_file;
|
||||
long hFile;
|
||||
strcat( path, "*.dll" );
|
||||
if (( hFile = ( long ) _findfirst( path, &c_file ) ) == -1L) //If there is no file matching our search
|
||||
return false;
|
||||
|
||||
do {
|
||||
files.push_back( strdup( c_file.name ));
|
||||
} while (_findnext( hFile, &c_file ) == 0);
|
||||
|
||||
_findclose( hFile );
|
||||
return true;
|
||||
}
|
||||
|
||||
#else // ! WIN32
|
||||
|
||||
bool static FindFiles( char* path, std::list<char*> &files )
|
||||
{
|
||||
DirectoryIterator dir(path);
|
||||
if (!dir) //If we cannot open the Directory
|
||||
return false;
|
||||
|
||||
do {
|
||||
const char *name = dir.GetName();
|
||||
if (fnmatch( "*.so", name, 0 ) != 0) //If the current file has no ".so" extension, skip it
|
||||
continue;
|
||||
files.push_back( strdup( name ));
|
||||
} while (++dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // ! WIN32
|
||||
|
||||
void LoadPlugins(char* pluginpath)
|
||||
{
|
||||
std::set<PluginID> libs;
|
||||
|
||||
printMessage("PluginMgr", "Loading Plugins from %s\n", WHITE, pluginpath);
|
||||
|
||||
char path[_MAX_PATH];
|
||||
strcpy( path, pluginpath );
|
||||
|
||||
std::list< char * > files;
|
||||
if (! FindFiles( path, files ))
|
||||
return;
|
||||
|
||||
//Iterate through all the available modules to load
|
||||
int file_count = files.size (); // keeps track of first-pass files
|
||||
while (! files.empty()) {
|
||||
char* file = files.front();
|
||||
files.pop_front();
|
||||
file_count--;
|
||||
|
||||
PathJoin( path, pluginpath, file, NULL );
|
||||
printBracket( "PluginMgr", LIGHT_WHITE );
|
||||
print( ": Loading: " );
|
||||
textcolor( LIGHT_WHITE );
|
||||
print( "%s", path );
|
||||
textcolor( WHITE );
|
||||
print( "..." );
|
||||
|
||||
|
||||
ieDword flags = 0;
|
||||
core->plugin_flags->Lookup (file, flags);
|
||||
|
||||
// module is sent to the back
|
||||
if ((flags == PLF_DELAY) && (file_count >= 0)) {
|
||||
printStatus( "DELAYING", YELLOW );
|
||||
files.push_back( file );
|
||||
continue;
|
||||
}
|
||||
|
||||
// We do not need the basename anymore now
|
||||
free( file );
|
||||
|
||||
// module is skipped
|
||||
if (flags == PLF_SKIP) {
|
||||
printStatus( "SKIPPING", YELLOW );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Try to load the Module
|
||||
#ifdef WIN32
|
||||
HMODULE hMod = LoadLibrary( path );
|
||||
#else
|
||||
// Note: the RTLD_GLOBAL is necessary to export symbols to modules
|
||||
// which python may have to dlopen (-wjp, 20060716)
|
||||
// (to reproduce, try 'import bz2' or another .so module)
|
||||
void* hMod = dlopen( path, RTLD_NOW | RTLD_GLOBAL );
|
||||
#endif
|
||||
if (hMod == NULL) {
|
||||
printBracket( "ERROR", LIGHT_RED );
|
||||
print( "\nCannot Load Module, Skipping...\n" );
|
||||
PRINT_DLERROR;
|
||||
continue;
|
||||
}
|
||||
|
||||
//printStatus( "OK", LIGHT_GREEN );
|
||||
//using C bindings, so we don't need to jump through extra hoops
|
||||
//with the symbol name
|
||||
Version_t LibVersion = ( Version_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_Version" );
|
||||
Description_t Description = ( Description_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_Description" );
|
||||
ID_t ID = ( ID_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_ID" );
|
||||
Register_t Register = ( Register_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_Register" );
|
||||
|
||||
//printMessage( "PluginMgr", "Checking Plugin Version...", WHITE );
|
||||
if (LibVersion==NULL) {
|
||||
printStatus( "ERROR", LIGHT_RED );
|
||||
print( "Invalid Plug-in, Skipping...\n" );
|
||||
FREE_PLUGIN( hMod );
|
||||
continue;
|
||||
}
|
||||
if (strcmp(LibVersion(), VERSION_GEMRB) ) {
|
||||
printStatus( "ERROR", LIGHT_RED );
|
||||
print( "Plug-in Version not valid, Skipping...\n" );
|
||||
FREE_PLUGIN( hMod );
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginDesc desc = { hMod, ID(), Description(), Register };
|
||||
|
||||
//printStatus( "OK", LIGHT_GREEN );
|
||||
//printMessage( "PluginMgr", "Loading Exports for ", WHITE );
|
||||
print( " " );
|
||||
textcolor( LIGHT_WHITE );
|
||||
print( "%s", desc.Description );
|
||||
textcolor( WHITE );
|
||||
print( "..." );
|
||||
printStatus( "OK", LIGHT_GREEN );
|
||||
if (libs.find(desc.ID) != libs.end()) {
|
||||
printMessage( "PluginMgr", "Plug-in Already Loaded! ", WHITE );
|
||||
printStatus( "SKIPPING", YELLOW );
|
||||
FREE_PLUGIN( hMod );
|
||||
continue;
|
||||
}
|
||||
if (desc.Register != NULL) {
|
||||
if (!desc.Register(PluginMgr::Get())) {
|
||||
printMessage( "PluginMgr", "Plug-in Registration Failed! Perhaps a duplicate? ", WHITE );
|
||||
printStatus( "SKIPPING", YELLOW );
|
||||
FREE_PLUGIN( hMod );
|
||||
}
|
||||
}
|
||||
libs.insert(desc.ID);
|
||||
}
|
||||
}
|
||||
32
project/jni/application/gemrb/gemrb/core/PluginLoader.h
Normal file
32
project/jni/application/gemrb/gemrb/core/PluginLoader.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PLUGINLOADER_H
|
||||
#define PLUGINLOADER_H
|
||||
|
||||
/**
|
||||
* Loads GemRB plugins from shared libraries or DLLs.
|
||||
*
|
||||
* It goes over all appropriately named files in PluginPath directory
|
||||
* and tries to load them one after another.
|
||||
*/
|
||||
void LoadPlugins(char* pluginpath);
|
||||
|
||||
#endif
|
||||
@@ -14,60 +14,14 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "PluginMgr.h"
|
||||
|
||||
#include "win32def.h"
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Plugin.h"
|
||||
#include "ResourceDesc.h"
|
||||
#include "Variables.h" // FIXME: this should be in Interface.h instead
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
typedef const char* (*Version_t)(void);
|
||||
typedef const char* (*Description_t)(void);
|
||||
typedef PluginID (*ID_t)();
|
||||
typedef bool (* Register_t)(PluginMgr*);
|
||||
|
||||
#ifdef HAVE_FORBIDDEN_OBJECT_TO_FUNCTION_CAST
|
||||
#include <assert.h>
|
||||
typedef void *(* voidvoid)(void);
|
||||
inline voidvoid my_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
void *value = dlsym(handle,symbol);
|
||||
voidvoid ret;
|
||||
assert(sizeof(ret)==sizeof(value) );
|
||||
memcpy(&ret, &value, sizeof(ret) );
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#define my_dlsym dlsym
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define FREE_PLUGIN( handle ) FreeLibrary( handle )
|
||||
#define GET_PLUGIN_SYMBOL( handle, name ) GetProcAddress( handle, name )
|
||||
#define PRINT_DLERROR
|
||||
#else
|
||||
#define FREE_PLUGIN( handle ) dlclose( handle )
|
||||
#define GET_PLUGIN_SYMBOL( handle, name ) my_dlsym( handle, name )
|
||||
#define PRINT_DLERROR printf( "%s\n", dlerror() )
|
||||
#endif
|
||||
|
||||
PluginMgr *PluginMgr::Get()
|
||||
{
|
||||
@@ -79,172 +33,10 @@ PluginMgr::PluginMgr()
|
||||
{
|
||||
}
|
||||
|
||||
void PluginMgr::LoadPlugins(char* pluginpath)
|
||||
PluginMgr::~PluginMgr()
|
||||
{
|
||||
printMessage( "PluginMgr", "Loading Plugins from ", WHITE );
|
||||
printf( "%s\n", pluginpath );
|
||||
|
||||
char path[_MAX_PATH];
|
||||
strcpy( path, pluginpath );
|
||||
|
||||
std::list< char * > files;
|
||||
if (! FindFiles( path, files ))
|
||||
return;
|
||||
|
||||
//Iterate through all the available modules to load
|
||||
int file_count = files.size (); // keeps track of first-pass files
|
||||
while (! files.empty()) {
|
||||
char* file = files.front();
|
||||
files.pop_front();
|
||||
file_count--;
|
||||
|
||||
PathJoin( path, pluginpath, file, NULL );
|
||||
printBracket( "PluginMgr", LIGHT_WHITE );
|
||||
printf( ": Loading: " );
|
||||
textcolor( LIGHT_WHITE );
|
||||
printf( "%s", path );
|
||||
textcolor( WHITE );
|
||||
printf( "..." );
|
||||
|
||||
|
||||
ieDword flags = 0;
|
||||
core->plugin_flags->Lookup (file, flags);
|
||||
|
||||
// module is sent to the back
|
||||
if ((flags == PLF_DELAY) && (file_count >= 0)) {
|
||||
printStatus( "DELAYING", YELLOW );
|
||||
files.push_back( file );
|
||||
continue;
|
||||
}
|
||||
|
||||
// We do not need the basename anymore now
|
||||
free( file );
|
||||
|
||||
// module is skipped
|
||||
if (flags == PLF_SKIP) {
|
||||
printStatus( "SKIPPING", YELLOW );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Try to load the Module
|
||||
#ifdef WIN32
|
||||
HMODULE hMod = LoadLibrary( path );
|
||||
#else
|
||||
// Note: the RTLD_GLOBAL is necessary to export symbols to modules
|
||||
// which python may have to dlopen (-wjp, 20060716)
|
||||
// (to reproduce, try 'import bz2' or another .so module)
|
||||
void* hMod = dlopen( path, RTLD_NOW | RTLD_GLOBAL );
|
||||
#endif
|
||||
if (hMod == NULL) {
|
||||
printBracket( "ERROR", LIGHT_RED );
|
||||
printf( "\nCannot Load Module, Skipping...\n" );
|
||||
PRINT_DLERROR;
|
||||
continue;
|
||||
}
|
||||
|
||||
//printStatus( "OK", LIGHT_GREEN );
|
||||
//using C bindings, so we don't need to jump through extra hoops
|
||||
//with the symbol name
|
||||
Version_t LibVersion = ( Version_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_Version" );
|
||||
Description_t Description = ( Description_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_Description" );
|
||||
ID_t ID = ( ID_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_ID" );
|
||||
Register_t Register = ( Register_t ) GET_PLUGIN_SYMBOL( hMod, "GemRBPlugin_Register" );
|
||||
|
||||
//printMessage( "PluginMgr", "Checking Plugin Version...", WHITE );
|
||||
if (LibVersion==NULL) {
|
||||
printStatus( "ERROR", LIGHT_RED );
|
||||
printf( "Invalid Plug-in, Skipping...\n" );
|
||||
FREE_PLUGIN( hMod );
|
||||
continue;
|
||||
}
|
||||
if (strcmp(LibVersion(), VERSION_GEMRB) ) {
|
||||
printStatus( "ERROR", LIGHT_RED );
|
||||
printf( "Plug-in Version not valid, Skipping...\n" );
|
||||
FREE_PLUGIN( hMod );
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginDesc desc = { hMod, ID(), Description(), Register };
|
||||
|
||||
//printStatus( "OK", LIGHT_GREEN );
|
||||
//printMessage( "PluginMgr", "Loading Exports for ", WHITE );
|
||||
printf( " " );
|
||||
textcolor( LIGHT_WHITE );
|
||||
printf( "%s", desc.Description );
|
||||
textcolor( WHITE );
|
||||
printf( "..." );
|
||||
printStatus( "OK", LIGHT_GREEN );
|
||||
if (libs.find(desc.ID) != libs.end()) {
|
||||
printMessage( "PluginMgr", "Plug-in Already Loaded! ", WHITE );
|
||||
printStatus( "SKIPPING", YELLOW );
|
||||
FREE_PLUGIN( hMod );
|
||||
continue;
|
||||
}
|
||||
if (desc.Register != NULL) {
|
||||
if (!desc.Register(this)) {
|
||||
printMessage( "PluginMgr", "Plug-in Registration Failed! Perhaps a duplicate? ", WHITE );
|
||||
printStatus( "SKIPPING", YELLOW );
|
||||
FREE_PLUGIN( hMod );
|
||||
}
|
||||
}
|
||||
libs[desc.ID] = desc;
|
||||
}
|
||||
}
|
||||
|
||||
PluginMgr::~PluginMgr(void)
|
||||
{
|
||||
//don't free the shared libraries in debug mode, so valgrind can resolve the stack trace
|
||||
#ifndef _DEBUG
|
||||
for (unsigned int i = 0; i < libs.size(); i++) {
|
||||
#ifdef WIN32
|
||||
FreeLibrary(libs[i].handle);
|
||||
#else
|
||||
// dlclose(libs[i].handle);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
bool
|
||||
PluginMgr::FindFiles( char* path, std::list<char*> &files )
|
||||
{
|
||||
//The windows _findfirst/_findnext functions allow the use of wildcards so we'll use them :)
|
||||
struct _finddata_t c_file;
|
||||
long hFile;
|
||||
strcat( path, "*.dll" );
|
||||
if (( hFile = ( long ) _findfirst( path, &c_file ) ) == -1L) //If there is no file matching our search
|
||||
return false;
|
||||
|
||||
do {
|
||||
files.push_back( strdup( c_file.name ));
|
||||
} while (_findnext( hFile, &c_file ) == 0);
|
||||
|
||||
_findclose( hFile );
|
||||
return true;
|
||||
}
|
||||
|
||||
#else // ! WIN32
|
||||
|
||||
bool
|
||||
PluginMgr::FindFiles( char* path, std::list<char*> &files )
|
||||
{
|
||||
DirectoryIterator dir(path);
|
||||
if (!dir) //If we cannot open the Directory
|
||||
return false;
|
||||
|
||||
do {
|
||||
const char *name = dir.GetName();
|
||||
if (fnmatch( "*.so", name, 0 ) != 0) //If the current file has no ".so" extension, skip it
|
||||
continue;
|
||||
files.push_back( strdup( name ));
|
||||
} while (++dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // ! WIN32
|
||||
|
||||
bool PluginMgr::IsAvailable(SClass_ID plugintype) const
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "globals.h"
|
||||
#include "iless.h"
|
||||
#include "win32def.h"
|
||||
#include "Holder.h"
|
||||
|
||||
#include "ResourceDesc.h"
|
||||
|
||||
@@ -40,12 +41,6 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#ifdef WIN32
|
||||
typedef HINSTANCE LibHandle;
|
||||
#else
|
||||
typedef void *LibHandle;
|
||||
#endif
|
||||
|
||||
class Plugin;
|
||||
class Resource;
|
||||
class TypeID;
|
||||
@@ -64,19 +59,11 @@ public:
|
||||
public:
|
||||
/** Return global instance of PluginMgr */
|
||||
static PluginMgr* Get();
|
||||
void LoadPlugins(char* pluginpath);
|
||||
private:
|
||||
PluginMgr();
|
||||
public: // HACK: MSVC6 is buggy.
|
||||
~PluginMgr(void);
|
||||
~PluginMgr();
|
||||
private:
|
||||
struct PluginDesc {
|
||||
LibHandle handle;
|
||||
PluginID ID;
|
||||
const char *Description;
|
||||
bool (*Register)(PluginMgr*);
|
||||
};
|
||||
std::map< PluginID, PluginDesc> libs;
|
||||
std::map< SClass_ID, PluginFunc> plugins;
|
||||
std::map< const TypeID*, std::vector<ResourceDesc> > resources;
|
||||
/** Array of initializer functions */
|
||||
@@ -86,12 +73,10 @@ private:
|
||||
typedef std::map<const char*, PluginFunc, iless> driver_map;
|
||||
std::map<const TypeID*, driver_map> drivers;
|
||||
public:
|
||||
/** Return names of all *.so or *.dll files in the given directory */
|
||||
bool FindFiles( char* path, std::list< char* > &files);
|
||||
size_t GetPluginCount() const { return plugins.size(); }
|
||||
bool IsAvailable(SClass_ID plugintype) const;
|
||||
Plugin* GetPlugin(SClass_ID plugintype) const;
|
||||
|
||||
size_t GetPluginCount() const { return plugins.size(); }
|
||||
|
||||
/**
|
||||
* Register class plugin.
|
||||
@@ -150,4 +135,19 @@ public:
|
||||
Plugin* GetDriver(const TypeID* type, const char* name);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class PluginHolder : public Holder<T> {
|
||||
public:
|
||||
PluginHolder()
|
||||
{
|
||||
}
|
||||
PluginHolder(PluginID id)
|
||||
: Holder<T>(static_cast<T*>(PluginMgr::Get()->GetPlugin(id)))
|
||||
{
|
||||
}
|
||||
~PluginHolder()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -123,20 +123,20 @@ bool Gem_Polygon::PointIn(int tx, int ty) const
|
||||
|
||||
// returns twice the area of triangle a, b, c.
|
||||
// (can also be negative depending on orientation of a,b,c)
|
||||
inline int area2(const Point& a, const Point& b, const Point& c)
|
||||
static inline int area2(const Point& a, const Point& b, const Point& c)
|
||||
{
|
||||
return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
|
||||
}
|
||||
|
||||
|
||||
// return (c is to the left of a-b)
|
||||
inline bool left(const Point& a, const Point& b, const Point& c)
|
||||
static inline bool left(const Point& a, const Point& b, const Point& c)
|
||||
{
|
||||
return (area2(a, b, c) > 0);
|
||||
}
|
||||
|
||||
// { return (c is collinear with a-b)
|
||||
inline bool collinear(const Point& a, const Point& b, const Point& c)
|
||||
static inline bool collinear(const Point& a, const Point& b, const Point& c)
|
||||
{
|
||||
return (area2(a, b, c) == 0);
|
||||
}
|
||||
@@ -219,15 +219,13 @@ struct ScanlineInt {
|
||||
|
||||
};
|
||||
|
||||
|
||||
void Gem_Polygon::ComputeTrapezoids()
|
||||
{
|
||||
if (count < 3) return;
|
||||
//the loader never should load such a large polygon,
|
||||
//because the polygon count is supposed to be a 16 bit value
|
||||
if (count > 65535) {
|
||||
printMessage("Polygon", "Invalid Polygon!\n", LIGHT_RED);
|
||||
abort();
|
||||
error("Polygon", "Invalid Polygon!\n");
|
||||
}
|
||||
|
||||
trapezoids.clear();
|
||||
|
||||
@@ -22,12 +22,17 @@
|
||||
|
||||
#include "win32def.h"
|
||||
|
||||
#include "AnimationFactory.h"
|
||||
#include "Audio.h"
|
||||
#include "DisplayMessage.h"
|
||||
#include "Game.h"
|
||||
#include "GameData.h"
|
||||
#include "GlobalTimer.h"
|
||||
#include "Image.h"
|
||||
#include "Interface.h"
|
||||
#include "ProjectileServer.h"
|
||||
#include "Scriptable/Actor.h"
|
||||
#include "Sprite2D.h"
|
||||
#include "Video.h"
|
||||
|
||||
#include <cmath>
|
||||
@@ -250,14 +255,17 @@ void Projectile::GetPaletteCopy(Animation *anim[], Palette *&pal)
|
||||
}
|
||||
}
|
||||
|
||||
void Projectile::SetBlend()
|
||||
void Projectile::SetBlend(int brighten)
|
||||
{
|
||||
GetPaletteCopy(travel, palette);
|
||||
if (!palette)
|
||||
return;
|
||||
if (!palette->alpha) {
|
||||
palette->CreateShadedAlphaChannel();
|
||||
}
|
||||
}
|
||||
if (brighten) {
|
||||
palette->Brighten();
|
||||
}
|
||||
}
|
||||
|
||||
//create another projectile with type-1 (iterate magic missiles and call lightning)
|
||||
@@ -409,8 +417,8 @@ void Projectile::Setup()
|
||||
light = core->GetVideoDriver()->CreateLight(LightX, LightZ);
|
||||
}
|
||||
if (TFlags&PTF_BLEND) {
|
||||
SetBlend();
|
||||
}
|
||||
SetBlend(TFlags&PTF_BRIGHTEN);
|
||||
}
|
||||
if (SFlags&PSF_FLYING) {
|
||||
ZPos = FLY_HEIGHT;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user