forked from teamnwah/openmw-tes3coop
Improve logic and clarity of LocalPlayer's charGenThread()
Until now, the fact that charGenThread() returned false whenever the player had a menu open was preventing Main::UpdateWorld() from running at all with a menu open. The result was that no player packets from LocalPlayer::Update() were being sent by a player in a menu.
This commit is contained in:
parent
dc5bb32f2a
commit
729da2c0ba
1 changed files with 55 additions and 49 deletions
|
@ -76,63 +76,69 @@ void LocalPlayer::charGen(int stageFirst, int stageEnd)
|
||||||
bool LocalPlayer::charGenThread() // todo: need fix
|
bool LocalPlayer::charGenThread() // todo: need fix
|
||||||
{
|
{
|
||||||
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
||||||
if (windowManager->isGuiMode())
|
|
||||||
|
// If we haven't finished CharGen and we're in a menu, it must be
|
||||||
|
// one of the CharGen menus, so go no further until it's closed
|
||||||
|
if (windowManager->isGuiMode() && CharGenStage()->end != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (CharGenStage()->current >= CharGenStage()->end)
|
// If the current stage of CharGen is not the last one,
|
||||||
|
// move to the next one
|
||||||
|
else if (CharGenStage()->current < CharGenStage()->end)
|
||||||
{
|
{
|
||||||
|
switch (CharGenStage()->current)
|
||||||
if (GetNetworking()->isConnected() && CharGenStage()->current == CharGenStage()->end &&
|
|
||||||
CharGenStage()->end != 0)
|
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
case 0:
|
||||||
MWWorld::Ptr player = world->getPlayerPtr();
|
windowManager->pushGuiMode(MWGui::GM_Name);
|
||||||
(*Npc()) = *player.get<ESM::NPC>()->mBase;
|
break;
|
||||||
(*BirthSign()) = world->getPlayer().getBirthSign();
|
case 1:
|
||||||
|
windowManager->pushGuiMode(MWGui::GM_Race);
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server with my CharGen info");
|
break;
|
||||||
GetNetworking()->GetPlayerPacket(ID_GAME_BASE_INFO)->Send(this);
|
case 2:
|
||||||
|
windowManager->pushGuiMode(MWGui::GM_Class);
|
||||||
if (CharGenStage()->end != 1)
|
break;
|
||||||
{
|
case 3:
|
||||||
updateDynamicStats(true);
|
windowManager->pushGuiMode(MWGui::GM_Birth);
|
||||||
updateAttributes(true);
|
break;
|
||||||
updateSkills(true);
|
default:
|
||||||
updateLevel(true);
|
windowManager->pushGuiMode(MWGui::GM_Review);
|
||||||
sendClass();
|
break;
|
||||||
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this);
|
|
||||||
}
|
|
||||||
CharGenStage()->end = 0;
|
|
||||||
/*RakNet::BitStream bs;
|
|
||||||
GetNetworking()->GetPlayerPacket(ID_GAME_BASE_INFO)->Packet(&bs, this, true);
|
|
||||||
GetNetworking()->SendData(&bs);*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this);
|
||||||
|
CharGenStage()->current++;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (CharGenStage()->current)
|
// If we've reached the last stage of CharGen, send the
|
||||||
|
// corresponding packets and mark CharGen as finished
|
||||||
|
else if (CharGenStage()->end != 0)
|
||||||
{
|
{
|
||||||
case 0:
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
windowManager->pushGuiMode(MWGui::GM_Name);
|
MWWorld::Ptr player = world->getPlayerPtr();
|
||||||
break;
|
(*Npc()) = *player.get<ESM::NPC>()->mBase;
|
||||||
case 1:
|
(*BirthSign()) = world->getPlayer().getBirthSign();
|
||||||
windowManager->pushGuiMode(MWGui::GM_Race);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
windowManager->pushGuiMode(MWGui::GM_Class);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
windowManager->pushGuiMode(MWGui::GM_Birth);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
windowManager->pushGuiMode(MWGui::GM_Review);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this);
|
|
||||||
CharGenStage()->current++;
|
|
||||||
|
|
||||||
return false;
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server with my CharGen info");
|
||||||
|
GetNetworking()->GetPlayerPacket(ID_GAME_BASE_INFO)->Send(this);
|
||||||
|
|
||||||
|
// Send stats packets if this is the 2nd round of CharGen that
|
||||||
|
// only happens for new characters
|
||||||
|
if (CharGenStage()->end != 1)
|
||||||
|
{
|
||||||
|
updateDynamicStats(true);
|
||||||
|
updateAttributes(true);
|
||||||
|
updateSkills(true);
|
||||||
|
updateLevel(true);
|
||||||
|
sendClass();
|
||||||
|
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the last stage variable to 0 to indicate that CharGen is finished
|
||||||
|
CharGenStage()->end = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::updateDynamicStats(bool forceUpdate)
|
void LocalPlayer::updateDynamicStats(bool forceUpdate)
|
||||||
|
|
Loading…
Reference in a new issue