From: Alyssa M. <fu...@us...> - 2010-10-29 18:44:54
|
gemrb: Infinity Engine emulator The branch master has been updated via b04703b3df1dd559e4c15379d4ba13f4efeed35b (commit) Summary of changes: gemrb/core/DialogHandler.cpp | 15 +++++------ gemrb/core/DialogHandler.h | 8 +++--- gemrb/core/GUI/GameControl.cpp | 16 ++++++------ gemrb/core/GUI/GameControl.h | 8 ++---- gemrb/core/Game.cpp | 16 ++++++------ gemrb/core/Game.h | 4 +- gemrb/core/GameScript/Actions.cpp | 26 ++++++++++---------- gemrb/core/GameScript/GSUtils.cpp | 4 +- gemrb/core/GameScript/GameScript.cpp | 2 +- gemrb/core/GameScript/Matching.cpp | 4 +- gemrb/core/GameScript/Triggers.cpp | 19 ++++++-------- gemrb/core/Interface.cpp | 2 +- gemrb/core/Map.cpp | 20 +++++---------- gemrb/core/Map.h | 1 - gemrb/core/Projectile.cpp | 2 +- gemrb/core/Scriptable/Actor.cpp | 43 +++++++++++++------------------- gemrb/core/Scriptable/Actor.h | 10 +------ gemrb/core/Scriptable/ActorBlock.cpp | 33 ++++++++++-------------- gemrb/core/Scriptable/ActorBlock.h | 5 ++- gemrb/plugins/FXOpcodes/FXOpcodes.cpp | 2 +- gemrb/plugins/GUIScript/GUIScript.cpp | 2 +- 21 files changed, 106 insertions(+), 136 deletions(-) from 0d24ef2a77cea4221cf44603d12c9666a601024c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=b04703b3df1dd559e4c15379d4ba13f4efeed35b commit b04703b3df1dd559e4c15379d4ba13f4efeed35b Author: Alyssa Milburn <fu...@fu...> Date: Fri Oct 29 20:40:22 2010 +0200 remove localID, move globalID into Scriptable, use GetGlobalID() everywhere diff --git a/gemrb/core/DialogHandler.cpp b/gemrb/core/DialogHandler.cpp index 062a079..30e730e 100644 --- a/gemrb/core/DialogHandler.cpp +++ b/gemrb/core/DialogHandler.cpp @@ -69,7 +69,7 @@ int DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgr //linked to) Actor *spe = (Actor *) spk; - speakerID = spe->globalID; + speakerID = spe->GetGlobalID(); Actor *oldTarget = GetActorByGlobalID(targetID); if (tgt->Type!=ST_ACTOR) { targetID=0xffff; @@ -80,9 +80,9 @@ int DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlgr spk->LastTalkedTo=0; } else { Actor *tar = (Actor *) tgt; - speakerID = spe->globalID; - targetID = tar->globalID; - if (!originalTargetID) originalTargetID = tar->globalID; + speakerID = spe->GetGlobalID(); + targetID = tar->GetGlobalID(); + if (!originalTargetID) originalTargetID = tar->GetGlobalID(); spe->LastTalkedTo=targetID; tar->LastTalkedTo=speakerID; tar->SetCircleSize(); @@ -334,7 +334,7 @@ void DialogHandler::DialogChoose(unsigned int choose) return; } Actor *oldTarget = GetActorByGlobalID(targetID); - targetID = tgt->globalID; + targetID = tgt->GetGlobalID(); tgt->SetCircleSize(); if (oldTarget) oldTarget->SetCircleSize(); // we have to make a backup, tr->Dialog is freed @@ -430,7 +430,7 @@ end_of_choose: } // TODO: duplicate of the one in GameControl -Actor *DialogHandler::GetActorByGlobalID(ieWord ID) +Actor *DialogHandler::GetActorByGlobalID(ieDword ID) { if (!ID) return NULL; @@ -441,8 +441,7 @@ Actor *DialogHandler::GetActorByGlobalID(ieWord ID) Map* area = game->GetCurrentArea( ); if (!area) return NULL; - return - area->GetActorByGlobalID(ID); + return area->GetActorByGlobalID(ID); } Actor *DialogHandler::GetTarget() diff --git a/gemrb/core/DialogHandler.h b/gemrb/core/DialogHandler.h index ba58fb3..95a489f 100644 --- a/gemrb/core/DialogHandler.h +++ b/gemrb/core/DialogHandler.h @@ -31,14 +31,14 @@ public: ~DialogHandler(); private: /** this function safely retrieves an Actor by ID */ - Actor *GetActorByGlobalID(ieWord ID); + Actor *GetActorByGlobalID(ieDword ID); private: DialogState* ds; Dialog* dlg; public: - ieWord speakerID; - ieWord targetID; - ieWord originalTargetID; + ieDword speakerID; + ieDword targetID; + ieDword originalTargetID; //no idea if this is viable Scriptable *targetOB; public: diff --git a/gemrb/core/GUI/GameControl.cpp b/gemrb/core/GUI/GameControl.cpp index 7264f02..b005250 100644 --- a/gemrb/core/GUI/GameControl.cpp +++ b/gemrb/core/GUI/GameControl.cpp @@ -83,7 +83,7 @@ static ieResRef TestSpell="SPWI207"; //distance is the detection distance void GameControl::SetTracker(Actor *actor, ieDword dist) { - trackerID = actor->GetID(); + trackerID = actor->GetGlobalID(); distance = dist; } @@ -1251,7 +1251,7 @@ void GameControl::OnMouseOver(unsigned short x, unsigned short y) } if (lastActor) { - lastActorID = lastActor->globalID; + lastActorID = lastActor->GetGlobalID(); lastActor->SetOver( true ); ieDword type = lastActor->GetStat(IE_EA); if (type >= EA_EVILCUTOFF || type == EA_GOODBUTRED) { @@ -1605,7 +1605,7 @@ void GameControl::TryToTalk(Actor *source, Actor *tgt) source->ClearPath(); source->ClearActions(); strncpy(Tmp,"NIDSpecial1()",sizeof(Tmp) ); - dialoghandler->targetID = tgt->globalID; //this is a hack, but not so deadly + dialoghandler->targetID = tgt->GetGlobalID(); //this is a hack, but not so deadly source->AddAction( GenerateActionDirect( Tmp, tgt) ); } @@ -1705,7 +1705,7 @@ 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->GetID(); + trap->LastTriggerObject = trap->LastTrigger = actor->GetGlobalID(); trap->ImmediateEvent(); //directly feeding the event, even if there are actions in the queue trap->Scripts[0]->Update(); @@ -2200,7 +2200,7 @@ void GameControl::SetLastActor(Actor *actor, Actor *prevActor) if (!actor) { lastActorID = 0; } else { - lastActorID = actor->globalID; + lastActorID = actor->GetGlobalID(); actor->SetOver( true ); } } @@ -2616,9 +2616,9 @@ Sprite2D* GameControl::GetPortraitPreview(int pcslot) return img_scaled; } -Actor *GameControl::GetActorByGlobalID(ieWord ID) +Actor *GameControl::GetActorByGlobalID(ieDword globalID) { - if (!ID) + if (!globalID) return NULL; Game* game = core->GetGame(); if (!game) @@ -2628,7 +2628,7 @@ Actor *GameControl::GetActorByGlobalID(ieWord ID) if (!area) return NULL; return - area->GetActorByGlobalID(ID); + area->GetActorByGlobalID(globalID); } Actor *GameControl::GetLastActor() diff --git a/gemrb/core/GUI/GameControl.h b/gemrb/core/GUI/GameControl.h index 732868f..8faa5e5 100644 --- a/gemrb/core/GUI/GameControl.h +++ b/gemrb/core/GUI/GameControl.h @@ -102,10 +102,8 @@ public: static void MultipleQuickSaves(int arg); void SetTracker(Actor *actor, ieDword dist); private: - //Actor* lastActor; - //using global ID which is safer - ieWord lastActorID; - ieWord trackerID; + ieDword lastActorID; + ieDword trackerID; ieDword distance; //tracking distance std::vector< Actor*> highlighted; bool DrawSelectionRect; @@ -174,7 +172,7 @@ private: /** this function is called when the user presses 'q' (or equivalent) */ void QuickSave(); /** this function safely retrieves an Actor by ID */ - Actor *GetActorByGlobalID(ieWord ID); + Actor *GetActorByGlobalID(ieDword ID); void CalculateSelection(const Point &p); void ResizeDel(Window* win, int type); void ResizeAdd(Window* win, int type); diff --git a/gemrb/core/Game.cpp b/gemrb/core/Game.cpp index 3de6b1e..4811f07 100644 --- a/gemrb/core/Game.cpp +++ b/gemrb/core/Game.cpp @@ -202,17 +202,17 @@ Actor* Game::FindNPC(const char *scriptingname) return NULL; } -Actor *Game::GetGlobalActorByGlobalID(unsigned int objectID) +Actor *Game::GetGlobalActorByGlobalID(ieDword globalID) { unsigned int slot; for (slot=0; slot<PCs.size(); slot++) { - if (PCs[slot]->GetGlobalID()==objectID ) { + if (PCs[slot]->GetGlobalID()==globalID ) { return PCs[slot]; } } for (slot=0; slot<NPCs.size(); slot++) { - if (NPCs[slot]->GetGlobalID()==objectID ) { + if (NPCs[slot]->GetGlobalID()==globalID ) { return NPCs[slot]; } } @@ -327,7 +327,7 @@ int Game::LeaveParty (Actor* actor) std::vector< Actor*>::iterator m = PCs.begin() + slot; PCs.erase( m ); - ieDword id = actor->GetID(); + ieDword id = actor->GetGlobalID(); for ( m = PCs.begin(); m != PCs.end(); ++m) { (*m)->PCStats->LastLeft = id; if ( (*m)->InParty>actor->InParty) { @@ -412,7 +412,7 @@ int Game::JoinParty(Actor* actor, int join) //set the joining date actor->PCStats->JoinDate = GameTime; if (size) { - ieDword id = actor->GetID(); + ieDword id = actor->GetGlobalID(); for (size_t i=0;i<size; i++) { Actor *a = GetPC(i, false); a->PCStats->LastJoined = id; @@ -1214,7 +1214,7 @@ bool Game::PCInCombat(Actor* actor) const if (actor->LastTarget) { return true; } - if (AttackersOf(actor->GetID(), actor->GetCurrentArea())) { + if (AttackersOf(actor->GetGlobalID(), actor->GetCurrentArea())) { return true; } return false; @@ -1791,12 +1791,12 @@ void Game::DebugDump() } } -Actor *Game::GetActorByGlobalID(ieWord objectID) +Actor *Game::GetActorByGlobalID(ieDword globalID) { size_t mc = GetLoadedMapCount(); while(mc--) { Map *map = GetMap(mc); - Actor *actor = map->GetActorByGlobalID(objectID); + Actor *actor = map->GetActorByGlobalID(globalID); if (actor) return actor; } return NULL; diff --git a/gemrb/core/Game.h b/gemrb/core/Game.h index c889abe..2a88671 100644 --- a/gemrb/core/Game.h +++ b/gemrb/core/Game.h @@ -239,7 +239,7 @@ public: Actor* FindPC(unsigned int partyID); Actor* FindNPC(unsigned int partyID); /** Finds a global actor by global ID */ - Actor* GetGlobalActorByGlobalID(unsigned int globalID); + Actor* GetGlobalActorByGlobalID(ieDword globalID); /** Finds an actor in party, returns slot, if not there, returns -1*/ int InParty(Actor* pc) const; /** Finds an actor in store, returns slot, if not there, returns -1*/ @@ -408,7 +408,7 @@ public: /** Dumps information about the object */ void DebugDump(); /** Finds an actor by global ID */ - Actor *GetActorByGlobalID(ieWord objectID); + Actor *GetActorByGlobalID(ieDword objectID); /** updates the infravision info */ void Infravision(); private: diff --git a/gemrb/core/GameScript/Actions.cpp b/gemrb/core/GameScript/Actions.cpp index ae31f4e..1fe3f41 100644 --- a/gemrb/core/GameScript/Actions.cpp +++ b/gemrb/core/GameScript/Actions.cpp @@ -2505,8 +2505,8 @@ void GameScript::ToggleDoor(Scriptable* Sender, Action* /*parameters*/) } // should we be triggering the trap on close? - door->TriggerTrap(0, actor->GetID()); - door->SetDoorOpen( !door->IsOpen(), true, actor->GetID() ); + door->TriggerTrap(0, actor->GetGlobalID()); + door->SetDoorOpen( !door->IsOpen(), true, actor->GetGlobalID() ); } else { MoveNearerTo(Sender, *p, MAX_OPERATING_DISTANCE,0); return; @@ -4043,7 +4043,7 @@ void GameScript::SetGabber(Scriptable* Sender, Action* parameters) } GameControl* gc = core->GetGameControl(); if (gc->GetDialogueFlags()&DF_IN_DIALOG) { - gc->dialoghandler->speakerID = ((Actor *) tar)->globalID; + gc->dialoghandler->speakerID = tar->GetGlobalID(); } else { printMessage("GameScript","Can't set gabber!",YELLOW); } @@ -4538,10 +4538,10 @@ 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->GetID(); + tar->LastAttacker = snd->GetGlobalID(); } else { //pickpocket failed trigger - tar->LastOpenFailed = snd->GetID(); + tar->LastOpenFailed = snd->GetGlobalID(); } Sender->ReleaseCurrentAction(); return; @@ -5307,7 +5307,7 @@ void GameScript::MarkObject(Scriptable* Sender, Action* parameters) return; } Actor *actor = (Actor *) Sender; - actor->LastMarked = ((Actor *) tar)->GetID(); + actor->LastMarked = tar->GetGlobalID(); //if this doesn't modify LastSeen, then remove this line actor->LastSeen = actor->LastMarked; } @@ -5372,7 +5372,7 @@ void GameScript::MarkSpellAndObject(Scriptable* Sender, Action* parameters) } //mark spell and target me->LastMarkedSpell = splnum; - me->LastMarked = actor->GetID(); + me->LastMarked = actor->GetGlobalID(); break; end_mso_loop: pos++; @@ -5519,7 +5519,7 @@ void GameScript::UseContainer(Scriptable* Sender, Action* /*parameters*/) } Actor *actor = (Actor *)Sender; actor->SetModal(MS_NONE); - container->TriggerTrap(0, actor->GetID()); + container->TriggerTrap(0, actor->GetGlobalID()); core->SetCurrentContainer(actor, container, true); Sender->ReleaseCurrentAction(); return; @@ -6650,7 +6650,7 @@ void GameScript::FollowCreature(Scriptable* Sender, Action* parameters) } Actor *scr = (Actor *)Sender; Actor *actor = (Actor *)tar; - scr->LastFollowed = actor->GetID(); + scr->LastFollowed = actor->GetGlobalID(); scr->FollowOffset.empty(); if (!scr->InMove() || scr->Destination != actor->Pos) { scr->WalkTo(actor->Pos, 0, 1); @@ -6671,7 +6671,7 @@ void GameScript::RunFollow(Scriptable* Sender, Action* parameters) } Actor *scr = (Actor *)Sender; Actor *actor = (Actor *)tar; - scr->LastFollowed = actor->GetID(); + scr->LastFollowed = actor->GetGlobalID(); scr->FollowOffset.empty(); if (!scr->InMove() || scr->Destination != actor->Pos) { scr->WalkTo(actor->Pos, IF_RUNNING, 1); @@ -6706,8 +6706,8 @@ void GameScript::ProtectObject(Scriptable* Sender, Action* parameters) } Actor *scr = (Actor *)Sender; Actor *actor = (Actor *)tar; - scr->LastFollowed = actor->GetID(); - scr->LastProtected = actor->GetID(); + scr->LastFollowed = actor->GetGlobalID(); + scr->LastProtected = actor->GetGlobalID(); //not exactly range scr->FollowOffset.x = parameters->int0Parameter; scr->FollowOffset.y = parameters->int0Parameter; @@ -6738,7 +6738,7 @@ void GameScript::FollowObjectFormation(Scriptable* Sender, Action* parameters) } Actor *scr = (Actor *)Sender; Actor *actor = (Actor *)tar; - scr->LastFollowed = actor->GetID(); + scr->LastFollowed = actor->GetGlobalID(); ieDword formation = parameters->int0Parameter; ieDword pos = parameters->int1Parameter; scr->FollowOffset = gc->GetFormationOffset(formation, pos); diff --git a/gemrb/core/GameScript/GSUtils.cpp b/gemrb/core/GameScript/GSUtils.cpp index 88ec84a..c6b3f17 100644 --- a/gemrb/core/GameScript/GSUtils.cpp +++ b/gemrb/core/GameScript/GSUtils.cpp @@ -504,7 +504,7 @@ int SeeCore(Scriptable* Sender, Trigger* parameters, int justlos) if (Sender->Type==ST_ACTOR && tar->Type==ST_ACTOR) { Actor* snd = ( Actor* ) Sender; //additional checks for invisibility? - snd->LastSeen = ((Actor *) tar)->GetID(); + snd->LastSeen = tar->GetGlobalID(); } return 1; } @@ -1197,7 +1197,7 @@ void AttackCore(Scriptable *Sender, Scriptable *target, int flags) ieDword targetID = 0; if (target->Type==ST_ACTOR) { tar = (Actor *) target; - targetID = tar->GetID(); + targetID = tar->GetGlobalID(); } if (actor == tar) { Sender->ReleaseCurrentAction(); diff --git a/gemrb/core/GameScript/GameScript.cpp b/gemrb/core/GameScript/GameScript.cpp index 0e36349..d647c7f 100644 --- a/gemrb/core/GameScript/GameScript.cpp +++ b/gemrb/core/GameScript/GameScript.cpp @@ -2309,7 +2309,7 @@ Action* GenerateActionDirect(char *String, Actor *object) Action* action = GenerateAction(String); Object *tmp = action->objects[1]; if (tmp && tmp->objectFields[0]==-1) { - tmp->objectFields[1] = object->globalID; + tmp->objectFields[1] = object->GetGlobalID(); } action->pointParameter.empty(); return action; diff --git a/gemrb/core/GameScript/Matching.cpp b/gemrb/core/GameScript/Matching.cpp index b9ed4a2..4665a8a 100644 --- a/gemrb/core/GameScript/Matching.cpp +++ b/gemrb/core/GameScript/Matching.cpp @@ -301,7 +301,7 @@ Scriptable* GetStoredActorFromObject(Scriptable* Sender, Object* oC, int ga_flag if (tar && tar->Type == ST_ACTOR) { // .. but we only want objects created via objectFilters if (oC->objectFilters[0]) { - Sender->CurrentActionTarget = ((Actor *)tar)->globalID; + Sender->CurrentActionTarget = tar->GetGlobalID(); } } return tar; @@ -406,7 +406,7 @@ bool MatchActor(Scriptable *Sender, ieDword actorID, Object* oC) const targettype *tt = tgts->GetFirstTarget(m, ST_ACTOR); while (tt) { Actor *actor = (Actor *) tt->actor; - if (actor->GetID() == actorID) { + if (actor->GetGlobalID() == actorID) { ret = true; break; } diff --git a/gemrb/core/GameScript/Triggers.cpp b/gemrb/core/GameScript/Triggers.cpp index 21e0246..12e1057 100644 --- a/gemrb/core/GameScript/Triggers.cpp +++ b/gemrb/core/GameScript/Triggers.cpp @@ -235,7 +235,7 @@ int GameScript::IsValidForPartyDialog(Scriptable* Sender, Trigger* parameters) //for example the aaquatah dialog in irenicus dungeon depends on it GameControl *gc = core->GetGameControl(); Actor *pc = (Actor *) scr; - if (pc->globalID == gc->dialoghandler->targetID || pc->globalID==gc->dialoghandler->speakerID) { + if (pc->GetGlobalID() == gc->dialoghandler->targetID || pc->GetGlobalID()==gc->dialoghandler->speakerID) { return 0; } @@ -289,7 +289,7 @@ int GameScript::InPartyAllowDead(Scriptable* Sender, Trigger* parameters) int GameScript::InPartySlot(Scriptable* Sender, Trigger* parameters) { Actor *actor = core->GetGame()->GetPC(parameters->int0Parameter, false); - return MatchActor(Sender, actor->GetID(), parameters->objectParameter); + return MatchActor(Sender, actor->GetGlobalID(), parameters->objectParameter); } int GameScript::Exists(Scriptable* Sender, Trigger* parameters) @@ -316,7 +316,7 @@ int GameScript::IsGabber(Scriptable* Sender, Trigger* parameters) if (!scr || scr->Type!=ST_ACTOR) { return 0; } - if (((Actor *) scr)->globalID == core->GetGameControl()->dialoghandler->speakerID) + if (scr->GetGlobalID() == core->GetGameControl()->dialoghandler->speakerID) return 1; return 0; } @@ -2362,7 +2362,7 @@ int GameScript::SetLastMarkedObject(Scriptable* Sender, Trigger* parameters) return 0; } Actor* actor = ( Actor* ) tar; - scr->LastMarked = actor->GetID(); + scr->LastMarked = actor->GetGlobalID(); return 1; } @@ -3309,9 +3309,8 @@ int GameScript::NullDialog(Scriptable* Sender, Trigger* parameters) if (tar->Type != ST_ACTOR) { return 0; } - Actor *actor = (Actor *) tar; GameControl *gc = core->GetGameControl(); - if ( (actor->globalID != gc->dialoghandler->targetID) && (actor->globalID != gc->dialoghandler->speakerID) ) { + if ( (tar->GetGlobalID() != gc->dialoghandler->targetID) && (tar->GetGlobalID() != gc->dialoghandler->speakerID) ) { return 1; } return 0; @@ -3456,12 +3455,10 @@ int GameScript::InteractingWith(Scriptable* Sender, Trigger* parameters) return 0; } GameControl *gc = core->GetGameControl(); - Actor *pc = (Actor *) Sender; - if (pc->globalID != gc->dialoghandler->targetID && pc->globalID != gc->dialoghandler->speakerID) { + if (Sender->GetGlobalID() != gc->dialoghandler->targetID && Sender->GetGlobalID() != gc->dialoghandler->speakerID) { return 0; } - pc = (Actor *) tar; - if (pc->globalID != gc->dialoghandler->targetID && pc->globalID != gc->dialoghandler->speakerID) { + if (tar->GetGlobalID() != gc->dialoghandler->targetID && tar->GetGlobalID() != gc->dialoghandler->speakerID) { return 0; } return 1; @@ -3543,7 +3540,7 @@ int GameScript::AttackedBy(Scriptable* Sender, Trigger* parameters) while (tt) { Actor *actor = (Actor *) tt->actor; //if (actor->LastTarget == scr->GetID()) { - if (scr->LastAttacker == actor->GetID()) { + if (scr->LastAttacker == actor->GetGlobalID()) { if (!AStyle || (AStyle==actor->GetAttackStyle()) ) { scr->AddTrigger(&scr->LastAttacker); ret = 1; diff --git a/gemrb/core/Interface.cpp b/gemrb/core/Interface.cpp index da094aa..7885301 100644 --- a/gemrb/core/Interface.cpp +++ b/gemrb/core/Interface.cpp @@ -2623,7 +2623,7 @@ Actor *Interface::SummonCreature(const ieResRef resource, const ieResRef vvcres, } if (Owner && Owner->Type==ST_ACTOR) { - ab->LastSummoner = ((Actor *) Owner)->GetID(); + ab->LastSummoner = Owner->GetGlobalID(); } //Always use Base stats for the recently summoned creature diff --git a/gemrb/core/Map.cpp b/gemrb/core/Map.cpp index a1514d4..437d3f6 100644 --- a/gemrb/core/Map.cpp +++ b/gemrb/core/Map.cpp @@ -66,7 +66,6 @@ static Point **VisibilityMasks=NULL; static bool PathFinderInited = false; static Variables Spawns; static int LargeFog; -static ieWord globalActorCounter; void ReleaseSpawnGroup(void *poi) { @@ -303,12 +302,10 @@ Map::Map(void) InitPathFinder(); InitSpawnGroups(); InitExplore(); - globalActorCounter = 0; } ExploredBitmap = NULL; VisibleBitmap = NULL; version = 0; - localActorCounter = 0; MasterArea = core->GetGame()->MasterArea(scriptName); } @@ -543,7 +540,7 @@ void Map::UseExit(Actor *actor, InfoPoint *ip) return; } if (ip->Scripts[0]) { - ip->LastTriggerObject = ip->LastTrigger = ip->LastEntered = actor->GetID(); + ip->LastTriggerObject = ip->LastTrigger = ip->LastEntered = actor->GetGlobalID(); ip->ExecuteScript( 1 ); ip->ProcessActions(true); } @@ -1232,10 +1229,10 @@ void Map::Shout(Actor* actor, int shoutID, unsigned int radius) } } if (shoutID) { - listener->LastHeard = actor->GetID(); + listener->LastHeard = actor->GetGlobalID(); listener->LastShout = shoutID; } else { - listener->LastHelp = actor->GetID(); + listener->LastHelp = actor->GetGlobalID(); } } } @@ -1287,9 +1284,7 @@ void Map::AddActor(Actor* actor) { //setting the current area for the actor as this one strnlwrcpy(actor->Area, scriptName, 8); - //if actor->globalID was already set, don't change it - actor->SetMap(this, ++localActorCounter, - actor->globalID?actor->globalID:++globalActorCounter); + actor->SetMap(this); actors.push_back( actor ); //if a visible aggressive actor was put on the map, it is an autopause reason //guess game is always loaded? if not, then we'll crash @@ -1336,7 +1331,7 @@ void Map::DeleteActor(int i) //this frees up the spot under the feet circle ClearSearchMapFor( actor ); //remove the area reference from the actor - actor->SetMap(NULL,0,0); + actor->SetMap(NULL); //don't destroy the object in case it is a persistent object //otherwise there is a dead reference causing a crash on save if (!game->InStore(actor) ) { @@ -1353,12 +1348,11 @@ Actor* Map::GetActorByGlobalID(ieDword objectID) return NULL; } //truncation is intentional - ieWord globalID = (ieWord) objectID; size_t i = actors.size(); while (i--) { Actor* actor = actors[i]; - if (actor->globalID==globalID) { + if (actor->GetGlobalID()==objectID) { return actor; } } @@ -3516,7 +3510,7 @@ void Map::SeeSpellCast(Scriptable *caster, ieDword spell) return; } - LastCasterSeen = ((Actor *) caster)->GetID(); + LastCasterSeen = caster->GetGlobalID(); LastSpellSeen = spell; size_t i = actors.size(); diff --git a/gemrb/core/Map.h b/gemrb/core/Map.h index d9435da..113846c 100644 --- a/gemrb/core/Map.h +++ b/gemrb/core/Map.h @@ -234,7 +234,6 @@ public: ieByte* VisibleBitmap; int version; ieResRef WEDResRef; - ieWord localActorCounter; bool MasterArea; //this is set by the importer (not stored in the file) bool DayNight; diff --git a/gemrb/core/Projectile.cpp b/gemrb/core/Projectile.cpp index 9a04b1a..d759cce 100644 --- a/gemrb/core/Projectile.cpp +++ b/gemrb/core/Projectile.cpp @@ -412,7 +412,7 @@ Actor *Projectile::GetTarget() return NULL; } if (res==-1) { - Target = original->GetID(); + Target = original->GetGlobalID(); return NULL; } effects->SetOwner(original); diff --git a/gemrb/core/Scriptable/Actor.cpp b/gemrb/core/Scriptable/Actor.cpp index 53c665d..ddbf2a8 100644 --- a/gemrb/core/Scriptable/Actor.cpp +++ b/gemrb/core/Scriptable/Actor.cpp @@ -397,8 +397,6 @@ Actor::Actor() //set it to a neutral value ModalSpell[0] = '*'; LingeringModalSpell[0] = '*'; - //this one is saved, but not loaded? - localID = globalID = 0; //this one is not saved GotLUFeedback = false; RollSaves(); @@ -586,7 +584,7 @@ void Actor::SetCircleSize() } else if (Modified[IE_STATE_ID] & STATE_PANIC) { color = &yellow; color_index = 5; - } else if (gc && gc->dialoghandler->targetID == globalID && (gc->GetDialogueFlags()&DF_IN_DIALOG)) { + } else if (gc && gc->dialoghandler->targetID == GetGlobalID() && (gc->GetDialogueFlags()&DF_IN_DIALOG)) { color = &white; color_index = 3; //?? made up } else { @@ -2658,10 +2656,10 @@ int Actor::Damage(int damage, int damagetype, Scriptable *hitter, int modtype) //add lastdamagetype up ? maybe LastDamageType|=damagetype; if(hitter && hitter->Type==ST_ACTOR) { - LastHitter=((Actor *) hitter)->GetID(); + LastHitter=hitter->GetGlobalID(); } else { //Maybe it should be something impossible like 0xffff, and use 'Someone' - LastHitter=GetID(); + LastHitter=GetGlobalID(); } switch(modtype) @@ -2897,7 +2895,7 @@ void Actor::DebugDump() } printf( "\nArea: %.8s ", Area ); printf( "Dialog: %.8s\n", Dialog ); - printf( "Global ID: %d Local ID: %d\n", globalID, localID); + printf( "Global ID: %d\n", GetGlobalID()); printf( "Script name:%.32s\n", scriptName ); printf( "TalkCount: %d ", TalkCount ); printf( "PartySlot: %d\n", InParty ); @@ -2943,7 +2941,7 @@ const char* Actor::GetActorNameByID(ieDword ID) const return actor->GetScriptName(); } -void Actor::SetMap(Map *map, ieWord LID, ieWord GID) +void Actor::SetMap(Map *map) { //Did we have an area? bool effinit=!GetCurrentArea(); @@ -2951,16 +2949,11 @@ void Actor::SetMap(Map *map, ieWord LID, ieWord GID) Scriptable::SetMap(map); //unless we just lost it, in that case clear up some fields and leave if (!map) { - //the local ID is surely illegal after the map is nulled - localID = 0; //more bits may or may not be needed InternalFlags &=~IF_CLEANUP; return; } - localID = LID; - globalID = GID; - //These functions are called once when the actor is first put in //the area. It already has all the items (including fist) at this //time and it is safe to call effects. @@ -3217,7 +3210,7 @@ void Actor::Die(Scriptable *killer) //Can't simply set Selected to false, game has its own little list Game *game = core->GetGame(); game->SelectActor(this, false, SELECT_NORMAL); - game->OutAttack(GetID()); + game->OutAttack(GetGlobalID()); displaymsg->DisplayConstantStringName(STR_DEATH, 0xffffff, this); DisplayStringCore(this, VB_DIE, DS_CONSOLE|DS_CONST ); @@ -3461,7 +3454,7 @@ bool Actor::CheckOnDeath() } // don't destroy actors currently in a dialog GameControl *gc = core->GetGameControl(); - if (gc && (globalID == gc->dialoghandler->targetID || globalID == gc->dialoghandler->speakerID)) { + if (gc && (GetGlobalID() == gc->dialoghandler->targetID || GetGlobalID() == gc->dialoghandler->speakerID)) { return false; } @@ -4010,9 +4003,9 @@ int Actor::GetAttackStyle() void Actor::AttackedBy( Actor *attacker) { - LastAttacker = attacker->GetID(); + LastAttacker = attacker->GetGlobalID(); Game * game = core->GetGame(); - game->InAttack(GetID() ); + game->InAttack(GetGlobalID() ); game->InAttack(LastAttacker); } @@ -4020,7 +4013,7 @@ void Actor::SetTarget( Scriptable *target) { if (target->Type==ST_ACTOR) { Actor *tar = (Actor *) target; - LastTarget = tar->GetID(); + LastTarget = tar->GetGlobalID(); tar->AttackedBy(this); } SetOrientation( GetOrient( target->Pos, Pos ), false ); @@ -4031,7 +4024,7 @@ void Actor::StopAttack() { SetStance(IE_ANI_READY); secondround = 0; - core->GetGame()->OutAttack(GetID()); + core->GetGame()->OutAttack(GetGlobalID()); InternalFlags|=IF_TARGETGONE; //this is for the trigger! if (InParty) { core->Autopause(AP_NOTARGET); @@ -4080,7 +4073,7 @@ void Actor::InitRound(ieDword gameTime) //is guaranteed to be the start of a round, and we only want roundTime //if we are attacking this round if (InternalFlags&IF_STOPATTACK) { - core->GetGame()->OutAttack(GetID()); + core->GetGame()->OutAttack(GetGlobalID()); roundTime = 0; return; } @@ -4706,7 +4699,7 @@ void Actor::UpdateActorState(ieDword gameTime) { StopAttack(); } else { printMessage("Attack","(Leaving attack)", GREEN); - core->GetGame()->OutAttack(GetID()); + core->GetGame()->OutAttack(GetGlobalID()); } roundTime = 0; @@ -4835,7 +4828,7 @@ void Actor::SetColorMod( ieDword location, RGBModifier::Type type, int speed, void Actor::SetLeader(Actor *actor, int xoffset, int yoffset) { - LastFollowed = actor->GetID(); + LastFollowed = actor->GetGlobalID(); FollowOffset.x = xoffset; FollowOffset.y = yoffset; } @@ -5119,7 +5112,7 @@ void Actor::Draw(const Region &screen) drawcircle = false; } // the speaker should get a circle even in cutscenes - if (gc->dialoghandler->targetID == globalID && (gc->GetDialogueFlags()&DF_IN_DIALOG)) { + if (gc->dialoghandler->targetID == GetGlobalID() && (gc->GetDialogueFlags()&DF_IN_DIALOG)) { drawcircle = true; } if (BaseStats[IE_STATE_ID]&STATE_DEAD || InternalFlags&IF_JUSTDIED) { @@ -5809,7 +5802,7 @@ bool Actor::UseItemPoint(ieDword slot, ieDword header, const Point &target, ieDw ChargeItem(slot, header, item, itm, flags&UI_SILENT); gamedata->FreeItem(itm,tmpresref, false); if (pro) { - pro->SetCaster(globalID); + pro->SetCaster(GetGlobalID()); GetCurrentArea()->AddProjectile(pro, Pos, target); return true; } @@ -5844,7 +5837,7 @@ bool Actor::UseItem(ieDword slot, ieDword header, Scriptable* target, ieDword fl gamedata->FreeItem(itm,tmpresref, false); if (pro) { //ieDword is unsigned!! - pro->SetCaster(globalID); + pro->SetCaster(GetGlobalID()); if(((int)header < 0) && !(flags&UI_MISS)) { //using a weapon ITMExtHeader *which = itm->GetWeaponHeader(header == (ieDword)-2); Effect* AttackEffect = EffectQueue::CreateEffect(fx_damage_ref, damage, (weapon_damagetype[which->DamageType])<<16, FX_DURATION_INSTANT_LIMITED); @@ -5855,7 +5848,7 @@ bool Actor::UseItem(ieDword slot, ieDword header, Scriptable* target, ieDword fl delete AttackEffect; attackProjectile = pro; } else //launch it now as we are not attacking - GetCurrentArea()->AddProjectile(pro, Pos, tar->globalID, false); + GetCurrentArea()->AddProjectile(pro, Pos, tar->GetGlobalID(), false); return true; } return false; diff --git a/gemrb/core/Scriptable/Actor.h b/gemrb/core/Scriptable/Actor.h index 84d728a..038acdd 100644 --- a/gemrb/core/Scriptable/Actor.h +++ b/gemrb/core/Scriptable/Actor.h @@ -250,8 +250,6 @@ public: ieDword InteractCount; //this is accessible in iwd2, probably exists in other games too ieDword appearance; ieDword ModalState; - ieWord globalID; - ieWord localID; int PathTries; //the # of previous tries to pick up a new walkpath public: #define LastTarget LastDisarmFailed @@ -361,8 +359,8 @@ public: void DebugDump(); /** fixes the feet circle */ void SetCircleSize(); - /** places the actor on the map with a unique object ID */ - void SetMap(Map *map, ieWord LID, ieWord GID); + /** places the actor on the map */ + void SetMap(Map *map); /** sets the actor's position, calculating with the nojump flag*/ void SetPosition(const Point &position, int jump, int radius=0); /** you better use SetStat, this stuff is only for special cases*/ @@ -397,10 +395,6 @@ public: /** Modifies the base stat value in different ways, returns difference */ int NewBase(unsigned int StatIndex, ieDword ModifierValue, ieDword ModifierType); void SetLeader(Actor *actor, int xoffset=0, int yoffset=0); - ieDword GetID() - { - return (localID<<16) | globalID; - } /** Sets the Icon ResRef */ //Which - 0 both, 1 Large, 2 Small void SetPortrait(const char* ResRef, int Which=0); diff --git a/gemrb/core/Scriptable/ActorBlock.cpp b/gemrb/core/Scriptable/ActorBlock.cpp index 9e32771..439096d 100644 --- a/gemrb/core/Scriptable/ActorBlock.cpp +++ b/gemrb/core/Scriptable/ActorBlock.cpp @@ -42,6 +42,8 @@ #define YESNO(x) ( (x)?"Yes":"No") +static ieDword globalActorCounter = 0; + /*********************** * Scriptable Class * ***********************/ @@ -76,6 +78,8 @@ Scriptable::Scriptable(ScriptableType type) lastDelay = 0; Dialog[0] = 0; + globalID = ++globalActorCounter; + interval = ( 1000 / AI_UPDATE_TIME ); WaitCounter = 0; if (Type == ST_ACTOR) { @@ -420,15 +424,6 @@ void Scriptable::ReleaseCurrentAction() CurrentActionInterruptable = true; } -ieWord Scriptable::GetGlobalID() -{ - if (Type == ST_ACTOR) { - Actor *actor = (Actor *) this; - return actor->globalID; - } - return 0; -} - void Scriptable::ProcessActions(bool force) { unsigned long thisTime = core->GetGame()->Ticks; @@ -681,7 +676,7 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool if (target && (Type==ST_ACTOR) ) { Actor *me = (Actor *) this; target->LastSpellOnMe = spellnum; - target->LastCasterOnMe = me->GetID(); + target->LastCasterOnMe = me->GetGlobalID(); // don't cure invisibility if this is a self targetting invisibility spell // like shadow door //can't check GetEffectBlock, since it doesn't construct the queue for selftargetting spells @@ -1836,11 +1831,11 @@ void Highlightable::TryDisarm(Actor *actor) { if (!Trapped || !TrapDetected) return; - LastTriggerObject = LastTrigger = actor->GetID(); + LastTriggerObject = LastTrigger = actor->GetGlobalID(); int skill = actor->GetStat(IE_TRAPS); if (skill/2+core->Roll(1,skill/2,0)>TrapRemovalDiff) { - LastDisarmed = actor->GetID(); + LastDisarmed = actor->GetGlobalID(); //trap removed Trapped = 0; displaymsg->DisplayConstantStringName(STR_DISARM_DONE, 0xd7d7be, actor); @@ -1866,12 +1861,12 @@ void Door::TryPickLock(Actor *actor) } if (actor->GetStat(IE_LOCKPICKING)<LockDifficulty) { displaymsg->DisplayConstantStringName(STR_LOCKPICK_FAILED, 0xbcefbc, actor); - LastPickLockFailed = actor->GetID(); + LastPickLockFailed = actor->GetGlobalID(); return; } SetDoorLocked( false, true); displaymsg->DisplayConstantStringName(STR_LOCKPICK_DONE, 0xd7d7be, actor); - LastUnlocked = actor->GetID(); + LastUnlocked = actor->GetGlobalID(); ImmediateEvent(); int xp = actor->CalculateExperience(XP_LOCKPICK, actor->GetXPLevel(1)); Game *game = core->GetGame(); @@ -1894,7 +1889,7 @@ void Door::TryBashLock(Actor *actor) displaymsg->DisplayConstantStringName(STR_DOORBASH_DONE, 0xd7d7be, actor); SetDoorLocked(false, true); //Is this really useful ? - LastUnlocked = actor->GetID(); + LastUnlocked = actor->GetGlobalID(); ImmediateEvent(); } @@ -2093,7 +2088,7 @@ check: //no need to avoid a travel trigger //skill? - if (TriggerTrap(0, actor->GetID()) ) { + if (TriggerTrap(0, actor->GetGlobalID()) ) { return true; } } @@ -2323,12 +2318,12 @@ void Container::TryPickLock(Actor *actor) } if (actor->GetStat(IE_LOCKPICKING)<LockDifficulty) { displaymsg->DisplayConstantStringName(STR_LOCKPICK_FAILED, 0xbcefbc, actor); - LastPickLockFailed = actor->GetID(); + LastPickLockFailed = actor->GetGlobalID(); return; } SetContainerLocked(false); displaymsg->DisplayConstantStringName(STR_LOCKPICK_DONE, 0xd7d7be, actor); - LastUnlocked = actor->GetID(); + LastUnlocked = actor->GetGlobalID(); ImmediateEvent(); int xp = actor->CalculateExperience(XP_LOCKPICK, actor->GetXPLevel(1)); Game *game = core->GetGame(); @@ -2351,7 +2346,7 @@ void Container::TryBashLock(Actor *actor) displaymsg->DisplayConstantStringName(STR_CONTBASH_DONE, 0xd7d7be, actor); SetContainerLocked(false); //Is this really useful ? - LastUnlocked = actor->GetID(); + LastUnlocked = actor->GetGlobalID(); ImmediateEvent(); } diff --git a/gemrb/core/Scriptable/ActorBlock.h b/gemrb/core/Scriptable/ActorBlock.h index 082212b..2e77808 100644 --- a/gemrb/core/Scriptable/ActorBlock.h +++ b/gemrb/core/Scriptable/ActorBlock.h @@ -169,6 +169,7 @@ private: // script_timers should probably be a std::map to // conserve memory (usually at most 2 ids are used) ieDword script_timers[MAX_TIMER]; + ieDword globalID; protected: //let Actor access this Map *area; ieVariable scriptName; @@ -179,7 +180,7 @@ protected: //let Actor access this Action* CurrentAction; public: int CurrentActionState; - ieWord CurrentActionTarget; + ieDword CurrentActionTarget; bool CurrentActionInterruptable; ieDword lastDelay; ieDword lastRunTime; @@ -270,7 +271,7 @@ public: /* spellcasting finished */ void CastSpellPointEnd( const ieResRef SpellResRef); void CastSpellEnd( const ieResRef SpellResRef); - ieWord GetGlobalID(); + ieDword GetGlobalID() const { return globalID; } /** timer functions (numeric ID, not saved) */ bool TimerActive(ieDword ID); bool TimerExpired(ieDword ID); diff --git a/gemrb/plugins/FXOpcodes/FXOpcodes.cpp b/gemrb/plugins/FXOpcodes/FXOpcodes.cpp index 2f19974..6ef5833 100644 --- a/gemrb/plugins/FXOpcodes/FXOpcodes.cpp +++ b/gemrb/plugins/FXOpcodes/FXOpcodes.cpp @@ -4506,7 +4506,7 @@ int fx_find_familiar (Scriptable* Owner, Actor* target, Effect* fx) return FX_NOT_APPLIED; } fam->SetBase(IE_EA, EA_FAMILIAR); - fam->LastSummoner = ((Actor *) Owner)->GetID(); + fam->LastSummoner = Owner->GetGlobalID(); Map *map = target->GetCurrentArea(); map->AddActor(fam); diff --git a/gemrb/plugins/GUIScript/GUIScript.cpp b/gemrb/plugins/GUIScript/GUIScript.cpp index dd45a94..0d54859 100644 --- a/gemrb/plugins/GUIScript/GUIScript.cpp +++ b/gemrb/plugins/GUIScript/GUIScript.cpp @@ -9276,7 +9276,7 @@ static PyObject* GemRB_StealFailed(PyObject * /*self*/, PyObject* /*args*/) //not sure if this is ok //owner->LastAttacker = attacker->GetID(); - owner->LastDisarmFailed = attacker->GetID(); + owner->LastDisarmFailed = attacker->GetGlobalID(); Py_INCREF( Py_None ); return Py_None; } ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |