adding a workaround to be able to start a network client from a server (with --no-graphics option)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13262 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hilnius 2013-07-16 22:27:28 +00:00
parent 766f9dfe70
commit 75e75c43ee
5 changed files with 34 additions and 18 deletions

View File

@ -1404,6 +1404,20 @@ int main(int argc, char *argv[] )
}
}
// no graphics, and no profile mode
if (ProfileWorld::isNoGraphics() && !ProfileWorld::isProfileMode())
{
// hack to have a running game slot :
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
if (UserConfigParams::m_default_player.toString().size() > 0)
for (int n=0; n<players.size(); n++)
if (players[n].getName() == UserConfigParams::m_default_player.toString())
unlock_manager->setCurrentSlot(players[n].getUniqueID());
main_loop->run();
throw "salut";
}
if(!UserConfigParams::m_no_start_screen)
{
StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance());

View File

@ -74,7 +74,7 @@ float MainLoop::getLimitedDt()
// Throttle fps if more than maximum, which can reduce
// the noise the fan on a graphics card makes.
// When in menus, reduce FPS much, it's not necessary to push to the maximum for plain menus
const int max_fps = (StateManager::get()->throttleFPS() ? 35 : UserConfigParams::m_max_fps);
const int max_fps = 35;//(StateManager::get()->throttleFPS() ? 35 : UserConfigParams::m_max_fps);
const int current_fps = (int)(1000.0f/dt);
if( current_fps > max_fps && !ProfileWorld::isProfileMode())
{
@ -155,6 +155,12 @@ void MainLoop::run()
PROFILER_SYNC_FRAME();
}
else if (!m_abort && ProfileWorld::isNoGraphics())
{
PROFILER_PUSH_CPU_MARKER("Protocol manager update", 0x7F, 0x00, 0x7F);
ProtocolManager::getInstance()->update();
PROFILER_POP_CPU_MARKER();
}
PROFILER_POP_CPU_MARKER();
} // while !m_exit

View File

@ -43,19 +43,13 @@ void KartUpdateProtocol::notifyEvent(Event* event)
{
uint32_t kart_id = event->data.getUInt32(0);
for (unsigned int i = 0; i < m_karts.size(); i++)
{
if (m_karts[i]->getWorldKartId() == kart_id)
{
float a,b,c;
a = ns.getFloat(4);
b = ns.getFloat(8);
c = ns.getFloat(12);
m_karts[i]->setXYZ(Vec3(a,b,c));
Log::info("KartUpdateProtocol", "Updating kart %i pos to %f %f %f", kart_id, a,b,c);
break;
}
}
float a,b,c;
a = ns.getFloat(4);
b = ns.getFloat(8);
c = ns.getFloat(12);
m_karts[kart_id]->setXYZ(Vec3(a,b,c));
Log::info("KartUpdateProtocol", "Updating kart %i pos to %f %f %f", kart_id, a,b,c);
ns.removeFront(16);
}
}
@ -68,7 +62,7 @@ void KartUpdateProtocol::update()
{
static double time = 0;
double current_time = Time::getRealTime();
if (current_time > time + 0.1) // 10 updates per second
if (current_time > time + 1) // 1 updates per second
{
if (m_listener->isServer())
{
@ -80,7 +74,7 @@ void KartUpdateProtocol::update()
Vec3 v = kart->getXYZ();
ns.ai32( kart->getWorldKartId());
ns.af(v[0]).af(v[1]).af(v[2]);
Log::info("KartUpdateProtocol", "Sending positions %f %f %f", v[0], v[1], v[2]);
Log::info("KartUpdateProtocol", "Sending %d's positions %f %f %f", kart->getWorldKartId(), v[0], v[1], v[2]);
}
m_listener->sendMessage(this, ns, false);
}
@ -92,7 +86,7 @@ void KartUpdateProtocol::update()
ns.af( World::getWorld()->getTime());
ns.ai32( kart->getWorldKartId());
ns.af(v[0]).af(v[1]).af(v[2]);
Log::info("KartUpdateProtocol", "Sending positions %f %f %f", v[0], v[1], v[2]);
Log::info("KartUpdateProtocol", "Sending %d's positions %f %f %f", kart->getWorldKartId(), v[0], v[1], v[2]);
m_listener->sendMessage(this, ns, false);
}
}

View File

@ -111,6 +111,7 @@ void StartGameProtocol::update()
rki.setLocalPlayerId(is_me?0:1);
rki.setHostId(profile->race_id);
PlayerProfile* profileToUse = unlock_manager->getCurrentPlayer();
assert(profileToUse);
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
int new_player_id = StateManager::get()->createActivePlayer( profileToUse, device , players[i]->user_profile);
device->setPlayer(StateManager::get()->getActivePlayer(new_player_id));

View File

@ -144,8 +144,9 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
assert(0<=player_id && player_id <m_local_player_karts.size());
assert(kart_properties_manager->getKart(kart) != NULL);
const PlayerProfile* profile = StateManager::get()->getActivePlayerProfile(player_id);
m_local_player_karts[player_id] = RemoteKartInfo(player_id, kart,
StateManager::get()->getActivePlayerProfile(player_id)->getName(),
profile->getName(),
0, false);
} // setLocalKartInfo