From e1f1461488d1e3553b33ac1ca450667cb4a760a3 Mon Sep 17 00:00:00 2001 From: Benau Date: Sun, 22 Nov 2015 15:01:22 +0800 Subject: [PATCH] Fix some bugs and copyright year --- .../controller/ai_base_lap_controller.cpp | 2 +- .../controller/ai_base_lap_controller.hpp | 2 +- src/karts/controller/battle_ai.cpp | 13 ++--- src/modes/three_strikes_battle.cpp | 12 +++-- src/race/race_manager.hpp | 2 +- src/states_screens/track_info_screen.cpp | 8 +++- src/tracks/battle_graph.cpp | 2 +- src/tracks/battle_graph.hpp | 2 +- src/tracks/nav_poly.hpp | 2 +- src/tracks/navmesh.hpp | 2 +- src/utils/debug.cpp | 47 +++++++++++++++++++ 11 files changed, 75 insertions(+), 19 deletions(-) diff --git a/src/karts/controller/ai_base_lap_controller.cpp b/src/karts/controller/ai_base_lap_controller.cpp index 25ca6f3cf..cac66798d 100644 --- a/src/karts/controller/ai_base_lap_controller.cpp +++ b/src/karts/controller/ai_base_lap_controller.cpp @@ -1,7 +1,7 @@ // // SuperTuxKart - a fun racing game with go-kart // Copyright (C) 2006-2009 Eduardo Hernandez Munoz -// Copyright (C) 2009, 2010 Joerg Henrichs +// Copyright (C) 2009-2015 Joerg Henrichs // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/karts/controller/ai_base_lap_controller.hpp b/src/karts/controller/ai_base_lap_controller.hpp index 3155894db..58749ac02 100644 --- a/src/karts/controller/ai_base_lap_controller.hpp +++ b/src/karts/controller/ai_base_lap_controller.hpp @@ -1,6 +1,6 @@ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2010 Joerg Henrichs +// Copyright (C) 2010-2015 Joerg Henrichs // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 3 diff --git a/src/karts/controller/battle_ai.cpp b/src/karts/controller/battle_ai.cpp index 8956e3b79..746be624b 100644 --- a/src/karts/controller/battle_ai.cpp +++ b/src/karts/controller/battle_ai.cpp @@ -18,15 +18,12 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//#define AI_DEBUG -#include -using namespace std; - +#undef AI_DEBUG #include "karts/controller/battle_ai.hpp" -//#ifdef AI_DEBUG +#ifdef AI_DEBUG #include "graphics/irr_driver.hpp" -//#endif +#endif #include "items/attachment.hpp" #include "items/item_manager.hpp" @@ -201,7 +198,7 @@ void BattleAI::handleSteering(const float dt) } } - //After this AI kart has a powerup, try to follow a closet kart in the map + // After this AI kart has a powerup, try to follow a closest kart in the map findClosestKart(&m_target_point , &m_target_node); if (m_target_node == BattleGraph::UNKNOWN_POLY) return; @@ -252,7 +249,7 @@ void BattleAI::findClosestKart(Vec3* aim_point, int* target_node) const AbstractKart* kart = m_world->getKart(i); if(kart->isEliminated()) continue; - if (kart->getXYZ() == m_kart->getXYZ()) + if (kart->getWorldKartId() == m_kart->getWorldKartId()) continue; // Skip the same kart Vec3 d = kart->getXYZ() - m_kart->getXYZ(); diff --git a/src/modes/three_strikes_battle.cpp b/src/modes/three_strikes_battle.cpp index 0f2f2b146..845d1a156 100644 --- a/src/modes/three_strikes_battle.cpp +++ b/src/modes/three_strikes_battle.cpp @@ -21,6 +21,7 @@ #include #include "audio/music_manager.hpp" +#include "config/user_config.hpp" #include "graphics/camera.hpp" #include "graphics/irr_driver.hpp" #include "io/file_manager.hpp" @@ -178,7 +179,8 @@ void ThreeStrikesBattle::kartHit(const unsigned int kart_id) if(wheels[1]) wheels[1]->setVisible(false); if(wheels[2]) wheels[2]->setVisible(false); if(wheels[3]) wheels[3]->setVisible(false); - eliminateKart(kart_id, /*notify_of_elimination*/ true); + if (getCurrentNumPlayers()) + eliminateKart(kart_id, /*notify_of_elimination*/ true); // Find a camera of the kart with the most lives ("leader"), and // attach all cameras for this kart to the leader. int max_lives = 0; @@ -196,7 +198,7 @@ void ThreeStrikesBattle::kartHit(const unsigned int kart_id) } // leader could be 0 if the last two karts hit each other in // the same frame - if(leader) + if(leader && getCurrentNumPlayers()) { for(unsigned int i=0; igetNumPlayers() < 2) + if (race_manager->getNumberOfKarts()==1 && + getCurrentNumKarts()==1 && + UserConfigParams::m_artist_debug_mode) { return false; } @@ -432,6 +436,8 @@ bool ThreeStrikesBattle::isRaceOver() */ void ThreeStrikesBattle::updateKartNodes() { + if (isRaceOver()) return; + const unsigned int n = getNumKarts(); for(unsigned int i=0; isetValue(num_ai); race_manager->setNumKarts(num_ai + race_manager->getNumLocalPlayers()); - m_ai_kart_spinner->setMax(stk_config->m_max_karts - race_manager->getNumLocalPlayers()); + // Currently battle arena only has 4 starting position + if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES) + { + m_ai_kart_spinner->setMax(4 - race_manager->getNumLocalPlayers()); + } + else + m_ai_kart_spinner->setMax(stk_config->m_max_karts - race_manager->getNumLocalPlayers()); // A ftl reace needs at least three karts to make any sense if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER) { diff --git a/src/tracks/battle_graph.cpp b/src/tracks/battle_graph.cpp index fc808ac48..a75828528 100644 --- a/src/tracks/battle_graph.cpp +++ b/src/tracks/battle_graph.cpp @@ -1,6 +1,6 @@ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009 Joerg Henrichs +// Copyright (C) 2009-2015 Joerg Henrichs // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/tracks/battle_graph.hpp b/src/tracks/battle_graph.hpp index 603aac3dc..aea60c41c 100644 --- a/src/tracks/battle_graph.hpp +++ b/src/tracks/battle_graph.hpp @@ -1,6 +1,6 @@ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009 Joerg Henrichs +// Copyright (C) 2009-2015 Joerg Henrichs // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/tracks/nav_poly.hpp b/src/tracks/nav_poly.hpp index 12f26ca53..175e6e826 100644 --- a/src/tracks/nav_poly.hpp +++ b/src/tracks/nav_poly.hpp @@ -1,6 +1,6 @@ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009 Joerg Henrichs +// Copyright (C) 2009-2015 Joerg Henrichs // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/tracks/navmesh.hpp b/src/tracks/navmesh.hpp index 1245dabe8..0a4890c86 100644 --- a/src/tracks/navmesh.hpp +++ b/src/tracks/navmesh.hpp @@ -1,6 +1,6 @@ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009 Joerg Henrichs +// Copyright (C) 2009-2015 Joerg Henrichs // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index 17544f18d..6fdb7f0cc 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -102,6 +102,10 @@ enum DebugMenuCommand DEBUG_GUI_CAM_NORMAL, DEBUG_GUI_CAM_SMOOTH, DEBUG_GUI_CAM_ATTACH, + DEBUG_VIEW_KART_ONE, + DEBUG_VIEW_KART_TWO, + DEBUG_VIEW_KART_THREE, + DEBUG_VIEW_KART_FOUR, DEBUG_HIDE_KARTS, DEBUG_THROTTLE_FPS, DEBUG_VISUAL_VALUES, @@ -154,7 +158,27 @@ void addAttachment(Attachment::AttachmentType type) } // addAttachment +// ---------------------------------------------------------------------------- +void changeCameraTarget(u32 num) +{ + World* world = World::getWorld(); + Camera *cam = Camera::getActiveCamera(); + if (world == NULL || cam == NULL) return; + + if ((num - 1) < (world->getNumKarts() + 1)) + { + AbstractKart* kart = world->getKart(num - 1); + if (kart->isEliminated()) return; + cam->setMode(Camera::CM_NORMAL); + cam->setKart(kart); + } + else + return; + +} // changeCameraTarget + // ----------------------------------------------------------------------------- + /** returns the light node with the lowest distance to the player kart (excluding * nitro emitters) */ LightNode* findNearestLight() @@ -452,6 +476,22 @@ bool handleContextMenuAction(s32 cmdID) Camera *cam = Camera::getActiveCamera(); cam->setAttachedFpsCam(!cam->getAttachedFpsCam()); } + else if (cmdID == DEBUG_VIEW_KART_ONE) + { + changeCameraTarget(1); + } + else if (cmdID == DEBUG_VIEW_KART_TWO) + { + changeCameraTarget(2); + } + else if (cmdID == DEBUG_VIEW_KART_THREE) + { + changeCameraTarget(3); + } + else if (cmdID == DEBUG_VIEW_KART_FOUR) + { + changeCameraTarget(4); + } else if (cmdID == DEBUG_PRINT_START_POS) { if (!world) return false; @@ -643,6 +683,13 @@ bool onEvent(const SEvent &event) sub->addItem(L"Toggle smooth camera", DEBUG_GUI_CAM_SMOOTH); sub->addItem(L"Attach fps camera to kart", DEBUG_GUI_CAM_ATTACH); + mnu->addItem(L"Change camera target >",-1,true, true); + sub = mnu->getSubMenu(4); + sub->addItem(L"To kart one", DEBUG_VIEW_KART_ONE); + sub->addItem(L"To kart two", DEBUG_VIEW_KART_TWO); + sub->addItem(L"To kart three", DEBUG_VIEW_KART_THREE); + sub->addItem(L"To kart four", DEBUG_VIEW_KART_FOUR); + mnu->addItem(L"Adjust values", DEBUG_VISUAL_VALUES); mnu->addItem(L"Profiler", DEBUG_PROFILER);