From: <ave...@us...> - 2009-09-27 19:01:34
|
Revision: 7278 http://gemrb.svn.sourceforge.net/gemrb/?rev=7278&view=rev Author: avenger_teambg Date: 2009-09-27 19:01:23 +0000 (Sun, 27 Sep 2009) Log Message: ----------- DeathVarFormat is now available via Interface separated effectqueue update and cleanup more consts in Interface Use the locals of the actor in player1d (it is not yet clear in which context this script runs) Modified Paths: -------------- gemrb/trunk/gemrb/plugins/Core/Actor.cpp gemrb/trunk/gemrb/plugins/Core/EffectQueue.cpp gemrb/trunk/gemrb/plugins/Core/EffectQueue.h gemrb/trunk/gemrb/plugins/Core/Game.cpp gemrb/trunk/gemrb/plugins/Core/Interface.cpp gemrb/trunk/gemrb/plugins/Core/Interface.h gemrb/trunk/gemrb/plugins/Core/Triggers.cpp Modified: gemrb/trunk/gemrb/plugins/Core/Actor.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Actor.cpp 2009-09-27 18:28:22 UTC (rev 7277) +++ gemrb/trunk/gemrb/plugins/Core/Actor.cpp 2009-09-27 19:01:23 UTC (rev 7278) @@ -74,8 +74,8 @@ static int **levelslots = NULL; static int *dualswap = NULL; static int *maxhpconbon = NULL; -static ieVariable IWDDeathVarFormat = "KILL_%s_CNT"; -static ieVariable DeathVarFormat = "SPRITE_IS_DEAD%s"; +//static ieVariable IWDDeathVarFormat = "KILL_%s_CNT"; +//static ieVariable DeathVarFormat = "SPRITE_IS_DEAD%s"; static ieVariable CounterNames[4]={"GOOD","LAW","LADY","MURDER"}; static int FistRows = -1; @@ -1180,9 +1180,9 @@ { int i, j; - if (core->HasFeature(GF_IWD_DEATHVARFORMAT)) { - memcpy(DeathVarFormat, IWDDeathVarFormat, sizeof(ieVariable)); - } + //if (core->HasFeature(GF_IWD_DEATHVARFORMAT)) { + // memcpy(DeathVarFormat, IWDDeathVarFormat, sizeof(ieVariable)); + //} if (core->HasFeature(GF_CHALLENGERATING)) { sharexp=SX_DIVIDE|SX_CR; @@ -1999,11 +1999,11 @@ } // check if any new portrait icon was removed or added - if (PCStats && memcmp(PCStats->PreviousPortraitIcons, PCStats->PortraitIcons, sizeof(PCStats->PreviousPortraitIcons))) { - core->SetEventFlag(EF_PORTRAIT); - } if (PCStats) { - memcpy( PCStats->PreviousPortraitIcons, PCStats->PortraitIcons, sizeof(PCStats->PreviousPortraitIcons) ); + if (memcmp(PCStats->PreviousPortraitIcons, PCStats->PortraitIcons, sizeof(PCStats->PreviousPortraitIcons))) { + core->SetEventFlag(EF_PORTRAIT); + memcpy( PCStats->PreviousPortraitIcons, PCStats->PortraitIcons, sizeof(PCStats->PreviousPortraitIcons) ); + } } } @@ -2833,7 +2833,7 @@ game->kaputz->SetAt(varname, value+1); } } else { - snprintf(varname, 32, DeathVarFormat, scriptName); + snprintf(varname, 32, core->GetDeathVarFormat(), scriptName); game->locals->Lookup(varname, value); game->locals->SetAt(varname, value+1); } @@ -4032,6 +4032,9 @@ roundTime = 0; lastattack = 0; } + + //Avenger moved this here from ApplyAllEffects (this one modifies the effect queue) + fxqueue.Cleanup(); } //idx could be: 0-6, 16-22, 32-38, 48-54 Modified: gemrb/trunk/gemrb/plugins/Core/EffectQueue.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/EffectQueue.cpp 2009-09-27 18:28:22 UTC (rev 7277) +++ gemrb/trunk/gemrb/plugins/Core/EffectQueue.cpp 2009-09-27 19:01:23 UTC (rev 7278) @@ -312,7 +312,6 @@ for ( f = effects.begin(); f != effects.end(); f++ ) { delete (*f); - //delete( effects[i] ); } } @@ -352,7 +351,7 @@ //Change the location of an existing effect //this is used when some external code needs to adjust the effect's location //used when the gui sets the effect's final target -void EffectQueue::ModifyEffectPoint(EffectRef &effect_reference, ieDword x, ieDword y) +void EffectQueue::ModifyEffectPoint(EffectRef &effect_reference, ieDword x, ieDword y) const { ResolveEffectRef(effect_reference); if( effect_reference.EffText<0) { @@ -468,15 +467,18 @@ //this is where we reapply all effects when loading a saved game //The effects are already in the fxqueue of the target -void EffectQueue::ApplyAllEffects(Actor* target) +void EffectQueue::ApplyAllEffects(Actor* target) const { - //nah, we already been through this - //ieDword random_value = core->Roll( 1, 100, 0 ); - - std::list< Effect* >::iterator f; + std::list< Effect* >::const_iterator f; for ( f = effects.begin(); f != effects.end(); f++ ) { ApplyEffect( target, *f, 0 ); } +} + +void EffectQueue::Cleanup() +{ + std::list< Effect* >::iterator f; + for ( f = effects.begin(); f != effects.end(); ) { if( (*f)->TimingMode == FX_DURATION_JUST_EXPIRED) { delete *f; @@ -488,7 +490,7 @@ } //Handle the target flag when the effect is applied first -int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, Point &dest) +int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, Point &dest) const { int i; Game *game; @@ -658,7 +660,7 @@ //will get copied (hence the fxqueue.AddEffect call) //if this returns FX_NOT_APPLIED, then the whole stack was resisted //or expired -int EffectQueue::AddAllEffects(Actor* target, Point &destination) +int EffectQueue::AddAllEffects(Actor* target, Point &destination) const { int res = FX_NOT_APPLIED; // pre-roll dice for fx needing them and stow them in the effect @@ -1034,7 +1036,7 @@ // returns FX_ABORT if the whole spell this effect is in should be aborted // it will disable all future effects of same source (only on first apply) -int EffectQueue::ApplyEffect(Actor* target, Effect* fx, ieDword first_apply) +int EffectQueue::ApplyEffect(Actor* target, Effect* fx, ieDword first_apply) const { //printf( "FX 0x%02x: %s(%d, %d)\n", fx->Opcode, effectnames[fx->Opcode].Name, fx->Parameter1, fx->Parameter2 ); if( fx->Opcode >= MAX_EFFECTS) { @@ -1667,7 +1669,7 @@ return false; } -void EffectQueue::dump() +void EffectQueue::dump() const { printf( "EFFECT QUEUE:\n" ); int i = 0; Modified: gemrb/trunk/gemrb/plugins/Core/EffectQueue.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/EffectQueue.h 2009-09-27 18:28:22 UTC (rev 7277) +++ gemrb/trunk/gemrb/plugins/Core/EffectQueue.h 2009-09-27 19:01:23 UTC (rev 7278) @@ -182,13 +182,15 @@ /** Adds an Effect to the queue, subject to level and other checks. * Returns FX_ABORT is unsuccessful. fx is just a reference, AddEffect() * will malloc its own copy */ - int AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, Point &dest); + int AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, Point &dest) const; /** Removes first Effect matching fx from the queue. * Effects are matched based on their contents */ bool RemoveEffect(Effect* fx); - int AddAllEffects(Actor* target, Point &dest); - void ApplyAllEffects(Actor* target); + int AddAllEffects(Actor* target, Point &dest) const; + void ApplyAllEffects(Actor* target) const; + /** remove effects marked for removal */ + void Cleanup(); /* directly removes effects with specified opcode, use effect_reference when you can */ void RemoveAllEffects(ieDword opcode) const; @@ -214,7 +216,6 @@ void RemoveAllEffectsWithResource(EffectRef &effect_reference, const ieResRef resource) const; void RemoveLevelEffects(ieDword level, ieDword flags, ieDword match) const; - //Effect *GetEffect(ieDword idx) const; /* returns true if the timing method supports simplified duration */ static bool HasDuration(Effect *fx); /* returns true if the effect should be saved */ @@ -227,7 +228,7 @@ const Effect *GetNextSavedEffect(std::list< Effect* >::const_iterator &f) const; Effect *GetNextEffect(std::list< Effect* >::const_iterator &f) const; ieDword CountEffects(EffectRef &effect_reference, ieDword param1, ieDword param2, const char *ResRef) const; - void ModifyEffectPoint(EffectRef &effect_reference, ieDword x, ieDword y); + void ModifyEffectPoint(EffectRef &effect_reference, ieDword x, ieDword y) const; /* returns the number of saved effects */ ieDword GetSavedEffectsCount() const; size_t GetEffectsCount() const { return effects.size(); } @@ -261,12 +262,12 @@ // from pos, in range (no cone size yet) void AffectAllInRange(Map *map, Point &pos, int idstype, int idsvalue, unsigned int range, Actor *except); /** Lists contents of the queue on a terminal for debugging */ - void dump(); + void dump() const; //resolve effect static int ResolveEffect(EffectRef &effect_reference); static bool match_ids(Actor *target, int table, ieDword value); /** returns true if the process should abort applying a stack of effects */ - int ApplyEffect(Actor* target, Effect* fx, ieDword first_apply); + int ApplyEffect(Actor* target, Effect* fx, ieDword first_apply) const; private: /** counts effects of specific opcode, parameters and resource */ ieDword CountEffects(ieDword opcode, ieDword param1, ieDword param2, const char *ResRef) const; Modified: gemrb/trunk/gemrb/plugins/Core/Game.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Game.cpp 2009-09-27 18:28:22 UTC (rev 7277) +++ gemrb/trunk/gemrb/plugins/Core/Game.cpp 2009-09-27 19:01:23 UTC (rev 7278) @@ -1291,7 +1291,7 @@ Scriptable *Sender = GetPC(0,true); if (!Sender) return; - GameScript* gs = new GameScript( "player1d", ST_ACTOR);//, Sender->locals,0,0 ); + GameScript* gs = new GameScript( "player1d", ST_ACTOR, Sender->locals,0,0 ); gs->MySelf = Sender; gs->Update(); delete( gs ); Modified: gemrb/trunk/gemrb/plugins/Core/Interface.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Interface.cpp 2009-09-27 18:28:22 UTC (rev 7277) +++ gemrb/trunk/gemrb/plugins/Core/Interface.cpp 2009-09-27 19:01:23 UTC (rev 7278) @@ -97,6 +97,8 @@ static ieWordSigned *conmod = NULL; static ieWordSigned *chrmod = NULL; static ieWordSigned *lorebon = NULL; +static ieVariable IWDDeathVarFormat = "KILL_%s_CNT"; +static ieVariable DeathVarFormat = "SPRITE_IS_DEAD%s"; Interface::Interface(int iargc, char* iargv[]) { @@ -798,6 +800,12 @@ return flag; } +//Static +const char *Interface::GetDeathVarFormat() +{ + return DeathVarFormat; +} + int Interface::GetItemExcl(const ieResRef itemname) const { ieDword value; @@ -1527,6 +1535,11 @@ printStatus( "OK", LIGHT_GREEN ); } } + + if (HasFeature(GF_IWD_DEATHVARFORMAT)) { + memcpy(DeathVarFormat, IWDDeathVarFormat, sizeof(ieVariable)); + } + if (HasFeature( GF_HAS_BEASTS_INI )) { printMessage( "Core", "Loading beasts definition File...\n", WHITE ); Modified: gemrb/trunk/gemrb/plugins/Core/Interface.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Interface.h 2009-09-27 18:28:22 UTC (rev 7277) +++ gemrb/trunk/gemrb/plugins/Core/Interface.h 2009-09-27 19:01:23 UTC (rev 7278) @@ -644,6 +644,8 @@ char *GetMusicPlaylist(int SongType) const; /** Removes the extraneus EOL newline and carriage return */ void StripLine(char * string, size_t size); + /** Returns the DeathVarFormat of the day */ + static const char *GetDeathVarFormat(); private: int LoadSprites(); bool LoadConfig(void); Modified: gemrb/trunk/gemrb/plugins/Core/Triggers.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Triggers.cpp 2009-09-27 18:28:22 UTC (rev 7277) +++ gemrb/trunk/gemrb/plugins/Core/Triggers.cpp 2009-09-27 19:01:23 UTC (rev 7278) @@ -548,7 +548,7 @@ value = CheckVariable(Sender, parameters->string0Parameter, "KAPUTZ"); } else { ieVariable VariableName; - snprintf(VariableName,32, "SPRITE_IS_DEAD%s",parameters->string0Parameter); + snprintf(VariableName, 32, core->GetDeathVarFormat(), parameters->string0Parameter); value = CheckVariable(Sender, VariableName, "GLOBAL" ); } return ( value == (ieDword) parameters->int0Parameter ); @@ -562,7 +562,7 @@ value = CheckVariable(Sender, parameters->string0Parameter, "KAPUTZ"); } else { ieVariable VariableName; - snprintf(VariableName,32, "SPRITE_IS_DEAD%s",parameters->string0Parameter); + snprintf(VariableName, 32, core->GetDeathVarFormat(), parameters->string0Parameter); value = CheckVariable(Sender, VariableName, "GLOBAL" ); } return ( value > (ieDword) parameters->int0Parameter ); @@ -577,7 +577,7 @@ } else { ieVariable VariableName; - snprintf(VariableName,32, "SPRITE_IS_DEAD%s",parameters->string0Parameter); + snprintf(VariableName, 32, core->GetDeathVarFormat(), parameters->string0Parameter); value = CheckVariable(Sender, VariableName, "GLOBAL" ); } return ( value < (ieDword) parameters->int0Parameter ); @@ -1769,7 +1769,7 @@ if (core->HasFeature( GF_HAS_KAPUTZ )) { value = CheckVariable( Sender, parameters->string0Parameter, "KAPUTZ"); } else { - snprintf( Variable, 32, "SPRITE_IS_DEAD%s", parameters->string0Parameter ); + snprintf( Variable, 32, core->GetDeathVarFormat(), parameters->string0Parameter ); } value = CheckVariable( Sender, Variable, "GLOBAL" ); if (value>0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |