diff --git a/src/main.cpp b/src/main.cpp index 6f71c1e5d..5f205b59d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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& players = UserConfigParams::m_all_players; + if (UserConfigParams::m_default_player.toString().size() > 0) + for (int n=0; nsetCurrentSlot(players[n].getUniqueID()); + + main_loop->run(); + throw "salut"; + } + if(!UserConfigParams::m_no_start_screen) { StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance()); diff --git a/src/main_loop.cpp b/src/main_loop.cpp index 19fa41bb0..c10dbef49 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -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 diff --git a/src/network/protocols/kart_update_protocol.cpp b/src/network/protocols/kart_update_protocol.cpp index b57a9df66..e91408f76 100644 --- a/src/network/protocols/kart_update_protocol.cpp +++ b/src/network/protocols/kart_update_protocol.cpp @@ -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); } } diff --git a/src/network/protocols/start_game_protocol.cpp b/src/network/protocols/start_game_protocol.cpp index 958fd167a..554661c3f 100644 --- a/src/network/protocols/start_game_protocol.cpp +++ b/src/network/protocols/start_game_protocol.cpp @@ -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)); diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index 3991969ca..4038ea195 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -144,8 +144,9 @@ void RaceManager::setLocalKartInfo(unsigned int player_id, assert(0<=player_id && player_id 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