From: <ave...@us...> - 2009-08-22 20:09:32
|
Revision: 7015 http://gemrb.svn.sourceforge.net/gemrb/?rev=7015&view=rev Author: avenger_teambg Date: 2009-08-22 20:09:23 +0000 (Sat, 22 Aug 2009) Log Message: ----------- move actors to starting position in expansion Modified Paths: -------------- gemrb/trunk/gemrb/plugins/Core/Actions.cpp gemrb/trunk/gemrb/plugins/Core/Game.cpp gemrb/trunk/gemrb/plugins/Core/Game.h Modified: gemrb/trunk/gemrb/plugins/Core/Actions.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Actions.cpp 2009-08-22 19:49:31 UTC (rev 7014) +++ gemrb/trunk/gemrb/plugins/Core/Actions.cpp 2009-08-22 20:09:23 UTC (rev 7015) @@ -554,6 +554,13 @@ Game *game = core->GetGame(); game->SetExpansion(1); + + int i = game->GetPartySize(false); + while(i--) { + Actor *actor = game->GetPC(i, false); + game->InitActorPos(actor); + } + SaveGameIterator *sg = core->GetSaveGameIterator(); if (sg) { sg->Invalidate(); Modified: gemrb/trunk/gemrb/plugins/Core/Game.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Game.cpp 2009-08-22 19:49:31 UTC (rev 7014) +++ gemrb/trunk/gemrb/plugins/Core/Game.cpp 2009-08-22 20:09:23 UTC (rev 7015) @@ -312,34 +312,41 @@ } return false; } + +void Game::InitActorPos(Actor *actor) +{ + bool startorient = 0; + + AutoTable strta("startpos"); + // 0 - single player, 1 - tutorial, 2 - expansion + ieDword playmode = 0; + core->GetDictionary()->Lookup( "PlayMode", playmode ); + //hack for iwd2 + startorient = DetermineStartPosType(strta.ptr()); + if (startorient || strta->GetRowCount()<6) { + playmode %= 2; + actor->SetOrientation( atoi( strta->QueryField( playmode+4, actor->InParty-1) ), false ); + } + playmode *= 2; + actor->Pos.x = actor->Destination.x = (short) atoi( strta->QueryField( playmode, actor->InParty-1 ) ); + actor->Pos.y = actor->Destination.y = (short) atoi( strta->QueryField( playmode + 1, actor->InParty-1 ) ); + + strta.load("startare"); + playmode /= 2; + playmode *= 3; + strnlwrcpy(actor->Area, strta->QueryField( playmode, 0 ), 8 ); + //TODO: set viewport + + SelectActor(actor,true, SELECT_QUIET); +} + int Game::JoinParty(Actor* actor, int join) { - bool startorient = 0; actor->CreateStats(); //create stats if they didn't exist yet actor->InitButtons(actor->GetStat(IE_CLASS), false); //init actor's buttons actor->SetBase(IE_EXPLORE, 1); if (join&JP_INITPOS) { - AutoTable strta("startpos"); - // 0 - single player, 1 - tutorial, 2 - expansion - ieDword playmode = 0; - core->GetDictionary()->Lookup( "PlayMode", playmode ); - //hack for iwd2 - startorient = DetermineStartPosType(strta.ptr()); - if (startorient || strta->GetRowCount()<6) { - playmode %= 2; - actor->SetOrientation( atoi( strta->QueryField( playmode+4, actor->InParty-1) ), false ); - } - playmode *= 2; - actor->Pos.x = actor->Destination.x = (short) atoi( strta->QueryField( playmode, actor->InParty-1 ) ); - actor->Pos.y = actor->Destination.y = (short) atoi( strta->QueryField( playmode + 1, actor->InParty-1 ) ); - - strta.load("startare"); - playmode /= 2; - playmode *= 3; - strnlwrcpy(actor->Area, strta->QueryField( playmode, 0 ), 8 ); - //TODO: set viewport - - SelectActor(actor,true, SELECT_QUIET); + InitActorPos(actor); } int slot = InParty( actor ); if (slot != -1) { Modified: gemrb/trunk/gemrb/plugins/Core/Game.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Game.h 2009-08-22 19:49:31 UTC (rev 7014) +++ gemrb/trunk/gemrb/plugins/Core/Game.h 2009-08-22 20:09:23 UTC (rev 7015) @@ -247,6 +247,8 @@ Actor* FindPC(const char *deathvar); /** Finds an actor in store by scripting name*/ Actor* FindNPC(const char *deathvar); + /** Sets the area and position of the actor to the starting position */ + void InitActorPos(Actor *actor); /** Joins party */ int JoinParty(Actor* pc, int join=JP_JOIN); /** Return current party size */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |