Skip to content

Commit

Permalink
CommandActor: call stop before issuing new command
Browse files Browse the repository at this point in the history
enables more removal of repeated code
  • Loading branch information
bradallred committed Dec 14, 2013
1 parent 4315e90 commit b0f5afe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
9 changes: 0 additions & 9 deletions gemrb/core/GUI/GameControl.cpp
Expand Up @@ -1632,7 +1632,6 @@ void GameControl::TryToAttack(Actor *source, Actor *tgt)
{
char Tmp[40];

source->Stop();
strlcpy(Tmp, "NIDSpecial3()", sizeof(Tmp));
source->CommandActor(GenerateActionDirect( Tmp, tgt));
}
Expand All @@ -1642,7 +1641,6 @@ void GameControl::TryToDefend(Actor *source, Actor *tgt)
{
char Tmp[40];

source->Stop();
source->SetModal(MS_NONE);
strlcpy(Tmp, "NIDSpecial4()", sizeof(Tmp));
source->CommandActor(GenerateActionDirect( Tmp, tgt));
Expand All @@ -1655,7 +1653,6 @@ void GameControl::TryToPick(Actor *source, Scriptable *tgt)
{
char Tmp[40];

source->Stop();
source->SetModal(MS_NONE);
if (tgt->Type == ST_ACTOR) {
strlcpy(Tmp, "PickPockets([-1])", sizeof(Tmp));
Expand All @@ -1679,7 +1676,6 @@ void GameControl::TryToDisarm(Actor *source, InfoPoint *tgt)

char Tmp[40];

source->Stop();
source->SetModal(MS_NONE);
strlcpy(Tmp, "RemoveTraps([-1])", sizeof(Tmp));
source->CommandActor(GenerateActionDirect( Tmp, tgt ));
Expand Down Expand Up @@ -1797,7 +1793,6 @@ void GameControl::TryToTalk(Actor *source, Actor *tgt)
//(non interactive demo)
//i found no fitting action which would emulate this kind of
//dialog initation
source->Stop();
source->SetModal(MS_NONE);
strlcpy(Tmp, "NIDSpecial1()", sizeof(Tmp));
dialoghandler->targetID = tgt->GetGlobalID(); //this is a hack, but not so deadly
Expand All @@ -1824,7 +1819,6 @@ void GameControl::HandleContainer(Container *container, Actor *actor)
core->SetEventFlag(EF_RESETTARGET);

if (target_mode == TARGET_MODE_ATTACK) {
actor->Stop();
snprintf(Tmp, sizeof(Tmp), "BashDoor(\"%s\")", container->GetScriptName());
actor->CommandActor(GenerateAction(Tmp));
return;
Expand All @@ -1836,7 +1830,6 @@ void GameControl::HandleContainer(Container *container, Actor *actor)
}

container->AddTrigger(TriggerEntry(trigger_clicked, actor->GetGlobalID()));
actor->Stop();
strlcpy(Tmp, "UseContainer()", sizeof(Tmp));
core->SetCurrentContainer( actor, container);
actor->CommandActor(GenerateAction( Tmp));
Expand All @@ -1861,7 +1854,6 @@ void GameControl::HandleDoor(Door *door, Actor *actor)
core->SetEventFlag(EF_RESETTARGET);

if (target_mode == TARGET_MODE_ATTACK) {
actor->Stop();
snprintf(Tmp, sizeof(Tmp), "BashDoor(\"%s\")", door->GetScriptName());
actor->CommandActor(GenerateAction(Tmp));
return;
Expand All @@ -1873,7 +1865,6 @@ void GameControl::HandleDoor(Door *door, Actor *actor)
}

door->AddTrigger(TriggerEntry(trigger_clicked, actor->GetGlobalID()));
actor->Stop();
actor->TargetDoor = door->GetGlobalID();
// internal gemrb toggle door action hack - should we use UseDoor instead?
sprintf( Tmp, "NIDSpecial9()" );
Expand Down
3 changes: 2 additions & 1 deletion gemrb/core/Scriptable/Actor.cpp
Expand Up @@ -3549,7 +3549,8 @@ void Actor::PlaySelectionSound()
//call this when a PC receives a command from GUI
void Actor::CommandActor(Action* action)
{
AddAction(action);
Stop(); // stop what you were doing
AddAction(action); // now do this new thing
switch (cmd_snd_freq) {
case 0:
return;
Expand Down

0 comments on commit b0f5afe

Please sign in to comment.