From ed6e4ebfb453aa933d348c4e76330569c457bf7b Mon Sep 17 00:00:00 2001 From: hilnius <hilnius@178a84e3-b1eb-0310-8ba1-8eac791a3b58> Date: Fri, 5 Jul 2013 12:01:29 +0000 Subject: [PATCH] correcting the ai kart bug due to the former networking removal git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/networking@13088 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/items/attachment.cpp | 12 ----- src/items/flyable.cpp | 15 ------ src/items/flyable.hpp | 3 -- src/items/item_manager.cpp | 4 -- src/items/powerup.cpp | 1 - src/items/projectile_manager.cpp | 53 +------------------ src/items/projectile_manager.hpp | 1 - src/karts/controller/end_controller.cpp | 1 - src/karts/controller/kart_control.hpp | 1 - src/karts/controller/skidding_ai.cpp | 8 --- src/karts/kart.cpp | 20 ------- src/main.cpp | 6 +-- src/main_loop.cpp | 19 ------- src/modes/demo_world.cpp | 3 +- src/modes/linear_world.cpp | 9 +--- src/modes/overworld.cpp | 3 +- src/modes/world.cpp | 11 +--- src/modes/world_status.cpp | 3 -- src/physics/physics.cpp | 5 -- src/race/race_manager.cpp | 52 +++++++++++------- src/race/race_manager.hpp | 3 ++ .../dialogs/select_challenge.cpp | 2 +- .../dialogs/track_info_dialog.cpp | 1 - src/states_screens/help_screen_1.cpp | 3 +- src/states_screens/main_menu_screen.cpp | 3 +- 25 files changed, 48 insertions(+), 194 deletions(-) diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index 9e2699211..7d7fbb6a0 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -33,7 +33,6 @@ #include "karts/kart_properties.hpp" #include "modes/three_strikes_battle.hpp" #include "modes/world.hpp" -#include "network/network_manager.hpp" #include "utils/constants.hpp" /** Initialises the attachment each kart has. @@ -257,17 +256,6 @@ void Attachment::hitBanana(Item *item, int new_attachment) new_attachment = m_random.get(3); } // switch - // Save the information about the attachment in the race state - // so that the clients can be updated. - if(NetworkManager::getInstance()->isPlayingOnline()) // if we're online - { - /* - race_state->itemCollected(m_kart->getWorldKartId(), - item->getItemId(), - new_attachment);*/ -//NETWORK_UPDATE_PLZ - } - if (add_a_new_item) { switch (new_attachment) diff --git a/src/items/flyable.cpp b/src/items/flyable.cpp index 66f78c9c1..b1ee43129 100644 --- a/src/items/flyable.cpp +++ b/src/items/flyable.cpp @@ -409,21 +409,6 @@ bool Flyable::updateAndDelete(float dt) return false; } // updateAndDelete -// ---------------------------------------------------------------------------- -/** Updates the position of a projectile based on information received frmo the - * server. - */ -void Flyable::updateFromServer(const FlyableInfo &f, float dt) -{ -/* - setXYZ(f.m_xyz); - setRotation(f.m_rotation); -*/ - // Update the graphical position - Moveable::update(dt); - -} // updateFromServer - // ---------------------------------------------------------------------------- /** Returns true if the item hit the kart who shot it (to avoid that an item * that's too close to the shoter hits the shoter). diff --git a/src/items/flyable.hpp b/src/items/flyable.hpp index f15bd7cb4..9030209f3 100644 --- a/src/items/flyable.hpp +++ b/src/items/flyable.hpp @@ -19,7 +19,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//NETWORK_UPDATE_PLZ #ifndef HEADER_FLYABLE_HPP #define HEADER_FLYABLE_HPP @@ -35,7 +34,6 @@ using namespace irr; #include "tracks/terrain_info.hpp" class AbstractKart; -class FlyableInfo; class HitEffect; class PhysicalObject; class XMLNode; @@ -170,7 +168,6 @@ public: virtual bool updateAndDelete(float); virtual const core::stringw getHitString(const AbstractKart *kart) const = 0; virtual HitEffect* getHitEffect() const; - void updateFromServer(const FlyableInfo &f, float dt); bool isOwnerImmunity(const AbstractKart *kart_hit) const; virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL); void explode(AbstractKart* kart, PhysicalObject* obj=NULL, diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp index 529fd8793..a76db40fe 100644 --- a/src/items/item_manager.cpp +++ b/src/items/item_manager.cpp @@ -29,7 +29,6 @@ #include "io/file_manager.hpp" #include "karts/abstract_kart.hpp" #include "modes/linear_world.hpp" -#include "network/network_manager.hpp" #include "tracks/quad_graph.hpp" #include "tracks/track.hpp" #include "utils/string_utils.hpp" @@ -289,9 +288,6 @@ void ItemManager::collectedItem(Item *item, AbstractKart *kart, int add_info) */ void ItemManager::checkItemHit(AbstractKart* kart) { - // Only do this on the server - if(NetworkManager::getInstance()->isServer()) return; - // We could use m_items_in_quads to to check for item hits: take the quad // of the graph node of the kart, and only check items in that quad. But // then we also need to check for any adjacent quads (since an item just diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index 94dc7bb4d..a4264b16a 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -16,7 +16,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//NETWORK_UPDATE_PLZ #include "items/powerup.hpp" #include "audio/sfx_base.hpp" diff --git a/src/items/projectile_manager.cpp b/src/items/projectile_manager.cpp index 6ea6b8069..18e299560 100644 --- a/src/items/projectile_manager.cpp +++ b/src/items/projectile_manager.cpp @@ -16,8 +16,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//NETWORK_UPDATE_PLZ - #include "items/projectile_manager.hpp" #include "graphics/explosion.hpp" @@ -28,7 +26,6 @@ #include "items/powerup_manager.hpp" #include "items/powerup.hpp" #include "items/rubber_ball.hpp" -#include "network/network_manager.hpp" ProjectileManager *projectile_manager=0; @@ -67,15 +64,7 @@ void ProjectileManager::cleanup() /** General projectile update call. */ void ProjectileManager::update(float dt) { - - if(NetworkManager::getInstance()->isClient()) - { - updateClient(dt); - } - else - { - updateServer(dt); - } + updateServer(dt); HitEffects::iterator he = m_active_hit_effects.begin(); while(he!=m_active_hit_effects.end()) @@ -102,25 +91,10 @@ void ProjectileManager::update(float dt) /** Updates all rockets on the server (or no networking). */ void ProjectileManager::updateServer(float dt) { - // First update all projectiles on the track - - if(NetworkManager::getInstance()->isPlayingOnline()) //network_manager->getMode()!=NetworkManager::NW_NONE) - { - //race_state->setNumFlyables(m_active_projectiles.size()); - } - - Projectiles::iterator p = m_active_projectiles.begin(); while(p!=m_active_projectiles.end()) { bool can_be_deleted = (*p)->updateAndDelete(dt); - if(NetworkManager::getInstance()->isPlayingOnline()) //network_manager->getMode()!=NetworkManager::NW_NONE) - { - /*race_state->setFlyableInfo(p-m_active_projectiles.begin(), - FlyableInfo((*p)->getXYZ(), - (*p)->getRotation(), - can_be_deleted) );*/ - } if(can_be_deleted) { HitEffect *he = (*p)->getHitEffect(); @@ -137,31 +111,6 @@ void ProjectileManager::updateServer(float dt) } // updateServer -// ----------------------------------------------------------------------------- -/** Updates all rockets and hit effects on the client. - * updateClient takes the information in race_state and updates all rockets - * (i.e. position, hit effects etc) */ -void ProjectileManager::updateClient(float dt) -{ - /* - unsigned int num_projectiles = race_state->getNumFlyables(); - if(num_projectiles != m_active_projectiles.size()) - fprintf(stderr, "Warning: num_projectiles %d active %d\n", - num_projectiles, (int)m_active_projectiles.size()); - - unsigned int indx=0; - for(Projectiles::iterator i = m_active_projectiles.begin(); - i != m_active_projectiles.end(); ++i, ++indx) - { - const FlyableInfo &f = race_state->getFlyable(indx); - (*i)->updateFromServer(f, dt); - if(f.m_exploded) - { - (*i)->hit(NULL); - } - } // for i in m_active_projectiles - */ -} // updateClient // ----------------------------------------------------------------------------- Flyable *ProjectileManager::newProjectile(AbstractKart *kart, Track* track, PowerupManager::PowerupType type) diff --git a/src/items/projectile_manager.hpp b/src/items/projectile_manager.hpp index f0906ca6b..8fb513502 100644 --- a/src/items/projectile_manager.hpp +++ b/src/items/projectile_manager.hpp @@ -53,7 +53,6 @@ private: * being shown or have a sfx playing. */ HitEffects m_active_hit_effects; - void updateClient(float dt); void updateServer(float dt); public: ProjectileManager() {} diff --git a/src/karts/controller/end_controller.cpp b/src/karts/controller/end_controller.cpp index ccea9e9eb..8b72439c2 100644 --- a/src/karts/controller/end_controller.cpp +++ b/src/karts/controller/end_controller.cpp @@ -43,7 +43,6 @@ #include "karts/max_speed.hpp" #include "karts/rescue_animation.hpp" #include "modes/linear_world.hpp" -#include "network/network_manager.hpp" #include "race/race_manager.hpp" #include "states_screens/race_result_gui.hpp" #include "tracks/quad_graph.hpp" diff --git a/src/karts/controller/kart_control.hpp b/src/karts/controller/kart_control.hpp index 01619c4d5..ed330d820 100644 --- a/src/karts/controller/kart_control.hpp +++ b/src/karts/controller/kart_control.hpp @@ -19,7 +19,6 @@ #ifndef HEADER_KART_CONTROL_HPP #define HEADER_KART_CONTROL_HPP -//NETWORK_UPDATE_PLZ /** * \ingroup controller diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 029fb8a17..b75800b79 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -54,7 +54,6 @@ #include "items/powerup.hpp" #include "modes/linear_world.hpp" #include "modes/profile_world.hpp" -#include "network/network_manager.hpp" #include "race/race_manager.hpp" #include "tracks/quad_graph.hpp" #include "tracks/track.hpp" @@ -297,13 +296,6 @@ void SkiddingAI::update(float dt) return; #endif - // The client does not do any AI computations. - if(NetworkManager::getInstance()->isClient()) - { - AIBaseController::update(dt); - return; - } - // If the kart needs to be rescued, do it now (and nothing else) if(isStuck() && !m_kart->getKartAnimation()) { diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index bbf2714a4..0907c3d85 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -57,7 +57,6 @@ #include "karts/max_speed.hpp" #include "karts/skidding.hpp" #include "modes/linear_world.hpp" -#include "network/network_manager.hpp" #include "physics/btKart.hpp" #include "physics/btKartRaycast.hpp" #include "physics/btUprightConstraint.hpp" @@ -80,8 +79,6 @@ # include <math.h> #endif -//NETWORK_UPDATE_PLZ - /** The kart constructor. * \param ident The identifier for the kart model to use. * \param position The position (or rank) for this kart (between 1 and @@ -875,15 +872,6 @@ void Kart::collectedItem(Item *item, int add_info) default : break; } // switch TYPE - // Attachments and powerups are stored in the corresponding - // functions (hit{Red,Green}Item), so only coins need to be - // stored here. - /*if(NetworkManager::getInstance()->isServer() && - (type==Item::ITEM_NITRO_BIG || type==Item::ITEM_NITRO_SMALL) ) - { - race_state->itemCollected(getWorldKartId(), item->getItemId()); - }*/ - if ( m_collected_energy > m_kart_properties->getNitroMax()) m_collected_energy = m_kart_properties->getNitroMax(); m_controller->collectedItem(*item, add_info, old_energy); @@ -1015,14 +1003,6 @@ void Kart::update(float dt) m_slipstream->update(dt); - // Store the actual kart controls at the start of update in the server - // state. This makes it easier to reset some fields when they are not used - // anymore (e.g. controls.fire). - if(NetworkManager::getInstance()->isServer()) - { - //race_state->storeKartControls(*this); - } - if (!m_flying) { // When really on air, free fly, when near ground, try to glide / adjust for landing diff --git a/src/main.cpp b/src/main.cpp index 3a20a3610..9de152de3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1476,7 +1476,7 @@ int main(int argc, char *argv[] ) { // This will setup the race manager etc. history->Load(); -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(false); main_loop->run(); // well, actually run() will never return, since @@ -1494,7 +1494,7 @@ int main(int argc, char *argv[] ) // Quickstart (-N) // =============== // all defaults are set in InitTuxkart() -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(false); } } @@ -1504,7 +1504,7 @@ int main(int argc, char *argv[] ) // ========= race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD); -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(false); } main_loop->run(); diff --git a/src/main_loop.cpp b/src/main_loop.cpp index 321626bad..c025bb55a 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -29,7 +29,6 @@ #include "input/wiimote_manager.hpp" #include "modes/profile_world.hpp" #include "modes/world.hpp" -#include "network/network_manager.hpp" #include "race/race_manager.hpp" #include "states_screens/state_manager.hpp" #include "utils/profiler.hpp" @@ -94,21 +93,8 @@ float MainLoop::getLimitedDt() */ void MainLoop::updateRace(float dt) { - // Server: Send the current position and previous controls to all clients - // Client: send current controls to server - // But don't do this if the race is in finish phase (otherwise - // messages can be mixed up in the race manager) - /*if(!World::getWorld()->isFinishPhase()) - network_manager->sendUpdates();*/ if(ProfileWorld::isProfileMode()) dt=1.0f/60.0f; - // Again, only receive updates if the race isn't over - once the - // race results are displayed (i.e. game is in finish phase) - // messages must be handled by the normal update of the network - // manager - /*if(!World::getWorld()->isFinishPhase()) - network_manager->receiveUpdates();*/ - World::getWorld()->updateWorld(dt); } // updateRace @@ -127,13 +113,8 @@ void MainLoop::run() m_prev_time = m_curr_time; float dt = getLimitedDt(); -// network_manager->update(dt); - if (World::getWorld()) // race is active if world exists { - // Busy wait if race_manager is active (i.e. creating of world is done) - // till all clients have reached this state. - //if (network_manager->getState()==NetworkManager::NS_READY_SET_GO_BARRIER) continue; updateRace(dt); } // if race is active diff --git a/src/modes/demo_world.cpp b/src/modes/demo_world.cpp index 4801ab4cd..db0616866 100644 --- a/src/modes/demo_world.cpp +++ b/src/modes/demo_world.cpp @@ -21,7 +21,6 @@ #include "guiengine/modaldialog.hpp" #include "input/device_manager.hpp" #include "input/input_manager.hpp" -#include "network/network_manager.hpp" #include "race/race_manager.hpp" #include "tracks/track.hpp" #include "tracks/track_manager.hpp" @@ -149,7 +148,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt) m_do_demo = true; race_manager->setNumKarts(m_num_karts); race_manager->setLocalKartInfo(0, "tux"); -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startSingleRace(m_demo_tracks[0], m_num_laps, false); m_demo_tracks.push_back(m_demo_tracks[0]); m_demo_tracks.erase(m_demo_tracks.begin()); diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 610f4d629..5011f3696 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -25,7 +25,6 @@ #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" -#include "network/network_manager.hpp" #include "physics/physics.hpp" #include "race/history.hpp" #include "states_screens/race_gui_base.hpp" @@ -319,13 +318,7 @@ void LinearWorld::newLap(unsigned int kart_index) // Race finished if(kart_info.m_race_lap >= race_manager->getNumLaps() && raceHasLaps()) { - // A client does not detect race finished by itself, it will - // receive a message from the server. So a client does not do - // anything here. - /*if(network_manager->getMode()!=NetworkManager::NW_CLIENT) - { - kart->finishedRace(getTime()); - }*/ + kart->finishedRace(getTime()); } float time_per_lap; if (kart_info.m_race_lap == 1) // just completed first lap diff --git a/src/modes/overworld.cpp b/src/modes/overworld.cpp index 3a569810e..f301429d6 100644 --- a/src/modes/overworld.cpp +++ b/src/modes/overworld.cpp @@ -27,7 +27,6 @@ #include "karts/rescue_animation.hpp" #include "modes/overworld.hpp" #include "physics/physics.hpp" -#include "network/network_manager.hpp" #include "states_screens/dialogs/select_challenge.hpp" #include "states_screens/kart_selection.hpp" #include "states_screens/race_gui_overworld.hpp" @@ -83,7 +82,7 @@ void OverWorld::enterOverWorld() ->setSinglePlayer( StateManager::get()->getActivePlayer(0) ); StateManager::get()->enterGameState(); -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(false); if(race_manager->haveKartLastPositionOnOverworld()){ OverWorld *ow = (OverWorld*)World::getWorld(); diff --git a/src/modes/world.cpp b/src/modes/world.cpp index e5492d51c..2ee36dbe5 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -117,7 +117,6 @@ World::World() : WorldStatus(), m_clear_color(255,100,101,140) */ void World::init() { -// race_state = new RaceState(); m_faster_music_active = false; m_fastest_kart = 0; m_eliminated_karts = 0; @@ -173,8 +172,6 @@ void World::init() if(ReplayPlay::get()) ReplayPlay::get()->Load(); -// network_manager->worldLoaded(); - powerup_manager->updateWeightsForRace(num_karts); } // init @@ -359,7 +356,6 @@ World::~World() // gui and this must be deleted. delete m_race_gui; } -// delete race_state; for ( unsigned int i = 0 ; i < m_karts.size() ; i++ ) delete m_karts[i]; @@ -747,7 +743,7 @@ void World::updateWorld(float dt) ->setSinglePlayer( StateManager::get()->getActivePlayer(0) ); StateManager::get()->enterGameState(); -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(false); } else @@ -800,11 +796,8 @@ void World::update(float dt) if(ReplayPlay::get()) ReplayPlay::get()->update(dt); if(history->replayHistory()) dt=history->getNextDelta(); WorldStatus::update(dt); - // Clear race state so that new information can be stored -// race_state->clear(); -// if(network_manager->getMode()!=NetworkManager::NW_CLIENT && -// !history->dontDoPhysics()) + if (!history->dontDoPhysics()) { m_physics->update(dt); } diff --git a/src/modes/world_status.cpp b/src/modes/world_status.cpp index d3f4389e9..294009f1e 100644 --- a/src/modes/world_status.cpp +++ b/src/modes/world_status.cpp @@ -26,7 +26,6 @@ #include "karts/abstract_kart.hpp" #include "modes/world.hpp" #include "tracks/track.hpp" -#include "network/network_manager.hpp" #include <irrlicht.h> @@ -112,8 +111,6 @@ void WorldStatus::enterRaceOverState() */ void WorldStatus::terminateRace() { -// if(network_manager->getMode()==NetworkManager::NW_SERVER) -// network_manager->sendRaceResults(); } // terminateRace //----------------------------------------------------------------------------- diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 22a470b9b..5c528ff57 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -23,7 +23,6 @@ #include "karts/kart_properties.hpp" #include "karts/rescue_animation.hpp" #include "items/flyable.hpp" -#include "items/item.hpp" #include "modes/world.hpp" #include "graphics/stars.hpp" #include "karts/explosion_animation.hpp" @@ -159,8 +158,6 @@ void Physics::update(float dt) { AbstractKart *a=p->getUserPointer(0)->getPointerKart(); AbstractKart *b=p->getUserPointer(1)->getPointerKart(); -// race_state->addCollision(a->getWorldKartId(), -// b->getWorldKartId()); KartKartCollision(p->getUserPointer(0)->getPointerKart(), p->getContactPointCS(0), p->getUserPointer(1)->getPointerKart(), @@ -446,7 +443,6 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies, else if(upB->is(UserPointer::UP_KART)) { AbstractKart *kart=upB->getPointerKart(); -// race_state->addCollision(kart->getWorldKartId()); int n = contact_manifold->getContactPoint(0).m_index0; const Material *m = n>=0 ? upA->getPointerTriangleMesh()->getMaterial(n) @@ -466,7 +462,6 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies, if(upB->is(UserPointer::UP_TRACK)) { AbstractKart *kart = upA->getPointerKart(); -// race_state->addCollision(kart->getWorldKartId()); int n = contact_manifold->getContactPoint(0).m_index1; const Material *m = n>=0 ? upB->getPointerTriangleMesh()->getMaterial(n) diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index d68334a2a..2c61ea0ad 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -42,7 +42,6 @@ #include "modes/world.hpp" #include "modes/three_strikes_battle.hpp" #include "modes/soccer_world.hpp" -#include "network/network_manager.hpp" #include "states_screens/grand_prix_lose.hpp" #include "states_screens/grand_prix_win.hpp" #include "states_screens/kart_selection.hpp" @@ -143,9 +142,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); -/* m_local_player_karts[player_id] = RemoteKartInfo(player_id, kart, + m_local_player_karts[player_id] = RemoteKartInfo(player_id, kart, StateManager::get()->getActivePlayerProfile(player_id)->getName(), - network_manager->getMyHostId());*/ + 0); } // setLocalKartInfo //----------------------------------------------------------------------------- @@ -293,7 +292,7 @@ void RaceManager::startNew(bool from_overworld) // Create the kart status data structure to keep track of scores, times, ... // ========================================================================== m_kart_status.clear(); - printf("%u %lu %lu\n", (unsigned int)m_num_karts, m_ai_kart_list.size(), m_player_karts.size()); + Log::verbose("RaceManager", "Nb of karts=%u, ai:%lu players:%lu\n", (unsigned int)m_num_karts, m_ai_kart_list.size(), m_player_karts.size()); assert((unsigned int)m_num_karts == m_ai_kart_list.size()+m_player_karts.size()); // First add the AI karts (randomly chosen) @@ -321,8 +320,7 @@ void RaceManager::startNew(bool from_overworld) // ------------------------------------------------- for(int i=m_player_karts.size()-1; i>=0; i--) { - KartType kt= KT_PLAYER; //(m_player_karts[i].getHostId()==network_manager->getMyHostId()) - //? KT_PLAYER : KT_NETWORK_PLAYER; + KartType kt= KT_PLAYER; m_kart_status.push_back(KartStatus(m_player_karts[i].getKartName(), i, m_player_karts[i].getLocalPlayerId(), m_player_karts[i].getGlobalPlayerId(), @@ -509,21 +507,10 @@ void RaceManager::next() } user_config->saveConfig(); } - -// if(network_manager->getMode()==NetworkManager::NW_SERVER) -// network_manager->beginReadySetGoBarrier(); -// else -// network_manager->setState(NetworkManager::NS_WAIT_FOR_RACE_DATA); startNextRace(); } else { - // Back to main menu. Change the state of the state of the - // network manager. -// if(network_manager->getMode()==NetworkManager::NW_SERVER) -// network_manager->setState(NetworkManager::NS_MAIN_MENU); -// else -// network_manager->setState(NetworkManager::NS_WAIT_FOR_AVAILABLE_CHARACTERS); exitRace(); } } // next @@ -753,7 +740,7 @@ void RaceManager::startGP(const GrandPrixData* gp, bool from_overworld) StateManager::get()->enterGameState(); setGrandPrix(*gp); setCoinTarget( 0 ); // Might still be set from a previous challenge -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX); startNew(from_overworld); @@ -778,9 +765,36 @@ void RaceManager::startSingleRace(const std::string &track_ident, setMajorMode(RaceManager::MAJOR_MODE_SINGLE); setCoinTarget( 0 ); // Might still be set from a previous challenge -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); startNew(from_overworld); } +//----------------------------------------------------------------------------- +/** Receive and store the information from sendKartsInformation() +*/ +void RaceManager::setupPlayerKartInfo() +{ + std::vector<RemoteKartInfo> m_kart_info; + + // Get the local kart info + for(unsigned int i=0; i<getNumLocalPlayers(); i++) + m_kart_info.push_back(getLocalKartInfo(i)); + + // Now sort by (hostid, playerid) + std::sort(m_kart_info.begin(), m_kart_info.end()); + + // Set the player kart information + setNumPlayers(m_kart_info.size()); + + // Set the global player ID for each player + for(unsigned int i=0; i<m_kart_info.size(); i++) + { + m_kart_info[i].setGlobalPlayerId(i); + setPlayerKart(i, m_kart_info[i]); + } + + computeRandomKartList(); +} // setupPlayerKartInfo + /* EOF */ diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index 82028b227..ef0f2b083 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -674,6 +674,9 @@ public: */ void startSingleRace(const std::string &track_ident, const int num_laps, bool from_overworld); + /** Receive and store the information from sendKartsInformation() + */ + void setupPlayerKartInfo(); bool raceWasStartedFromOverworld() const { diff --git a/src/states_screens/dialogs/select_challenge.cpp b/src/states_screens/dialogs/select_challenge.cpp index 2ff9a7a0c..c8267be1b 100644 --- a/src/states_screens/dialogs/select_challenge.cpp +++ b/src/states_screens/dialogs/select_challenge.cpp @@ -228,7 +228,7 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin } // Sets up kart info, including random list of kart for AI -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(true); irr_driver->hidePointer(); diff --git a/src/states_screens/dialogs/track_info_dialog.cpp b/src/states_screens/dialogs/track_info_dialog.cpp index 77d7822f7..9dab89fd1 100644 --- a/src/states_screens/dialogs/track_info_dialog.cpp +++ b/src/states_screens/dialogs/track_info_dialog.cpp @@ -28,7 +28,6 @@ #include "io/file_manager.hpp" #include "karts/kart_properties.hpp" #include "karts/kart_properties_manager.hpp" -#include "network/network_manager.hpp" #include "race/highscores.hpp" #include "race/highscore_manager.hpp" #include "race/race_manager.hpp" diff --git a/src/states_screens/help_screen_1.cpp b/src/states_screens/help_screen_1.cpp index a11e208e1..edd38a1f6 100644 --- a/src/states_screens/help_screen_1.cpp +++ b/src/states_screens/help_screen_1.cpp @@ -24,7 +24,6 @@ #include "input/device_manager.hpp" #include "input/input_manager.hpp" #include "karts/kart_properties_manager.hpp" -#include "network/network_manager.hpp" #include "race/race_manager.hpp" #include "states_screens/help_screen_2.hpp" #include "states_screens/help_screen_3.hpp" @@ -82,7 +81,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i ->setSinglePlayer( StateManager::get()->getActivePlayer(0) ); StateManager::get()->enterGameState(); -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(false); } else if (name == "category") diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index bd6288e7c..677d2c554 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -37,7 +37,6 @@ #include "modes/cutscene_world.hpp" #include "modes/overworld.hpp" #include "modes/demo_world.hpp" -#include "network/network_manager.hpp" #include "states_screens/online_screen.hpp" #include "states_screens/addons_screen.hpp" #include "states_screens/credits.hpp" @@ -332,7 +331,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, ->setSinglePlayer( StateManager::get()->getActivePlayer(0) ); StateManager::get()->enterGameState(); -// network_manager->setupPlayerKartInfo(); + race_manager->setupPlayerKartInfo(); race_manager->startNew(false); } else if (selection == "story")