merged updates from trunk to branch
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/battleAI@14308 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a1ee115963
commit
1c75270912
@ -1,5 +1,7 @@
|
||||
# CMakeLists.txt - wiiuse
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.1)
|
||||
|
||||
set(WIIUSE_SOURCES
|
||||
classic.c
|
||||
dynamics.c
|
||||
@ -29,7 +31,7 @@ endif()
|
||||
if(MSVC)
|
||||
add_definitions("/DWIIUSE_STATIC")
|
||||
add_library(wiiuse STATIC ${WIIUSE_SOURCES})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" /MTd)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MTd")
|
||||
else()
|
||||
add_library(wiiuse ${WIIUSE_SOURCES})
|
||||
endif()
|
||||
|
@ -201,10 +201,6 @@
|
||||
RelativePath="..\io.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\io_nix.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ir.c"
|
||||
>
|
||||
@ -233,10 +229,6 @@
|
||||
RelativePath="..\os.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\os_nix.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\os_win.c"
|
||||
>
|
||||
|
@ -102,11 +102,17 @@ typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
typedef int8_t int_fast8_t;
|
||||
// Redefinition with different type on VS 2012
|
||||
#if (_MSC_VER < 1700)
|
||||
typedef int16_t int_fast16_t;
|
||||
#endif
|
||||
typedef int32_t int_fast32_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
// Redefinition with different type on VS 2012
|
||||
#if (_MSC_VER < 1700)
|
||||
typedef uint16_t uint_fast16_t;
|
||||
#endif
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "io/xml_node.hpp"
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
|
||||
# define isnan _isnan
|
||||
|
@ -46,6 +46,9 @@ static PtrVector<UserConfigParam, REF> all_params;
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
const int UserConfig::m_current_config_version = 8;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
UserConfigParam::~UserConfigParam()
|
||||
{
|
||||
@ -649,13 +652,14 @@ bool UserConfig::loadConfig()
|
||||
}
|
||||
|
||||
// ---- Read config file version
|
||||
int configFileVersion = CURRENT_CONFIG_VERSION;
|
||||
if(root->get("version", &configFileVersion) < 1)
|
||||
int config_file_version = m_current_config_version;
|
||||
if(root->get("version", &config_file_version) < 1)
|
||||
{
|
||||
GUIEngine::showMessage( _("Your config file was malformed, so it was deleted and a new one will be created."), 10.0f);
|
||||
std::cerr << "Warning, malformed user config file! Contains no version\n";
|
||||
Log::error("UserConfig",
|
||||
"Warning, malformed user config file! Contains no version");
|
||||
}
|
||||
if (configFileVersion < CURRENT_CONFIG_VERSION)
|
||||
if (config_file_version < m_current_config_version)
|
||||
{
|
||||
// current version (8) is 100% incompatible with other versions (which were lisp)
|
||||
// so we just delete the old config. in the future, for smaller updates, we can
|
||||
@ -713,7 +717,6 @@ bool UserConfig::loadConfig()
|
||||
return true;
|
||||
} // loadConfig
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Write settings to config file. */
|
||||
void UserConfig::saveConfig()
|
||||
@ -732,7 +735,8 @@ void UserConfig::saveConfig()
|
||||
XMLWriter configfile(filename.c_str());
|
||||
|
||||
configfile << L"<?xml version=\"1.0\"?>\n";
|
||||
configfile << L"<stkconfig version=\"" << CURRENT_CONFIG_VERSION << L"\" >\n\n";
|
||||
configfile << L"<stkconfig version=\"" << m_current_config_version
|
||||
<< L"\" >\n\n";
|
||||
|
||||
const int paramAmount = all_params.size();
|
||||
for(int i=0; i<paramAmount; i++)
|
||||
|
@ -37,8 +37,6 @@
|
||||
cause an undefined game action now
|
||||
6: Added stick configurations.
|
||||
*/
|
||||
const int CURRENT_CONFIG_VERSION = 8;
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@ -348,10 +346,10 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX GroupUserConfigParam m_wiimote_group
|
||||
PARAM_DEFAULT( GroupUserConfigParam("WiiMote",
|
||||
"Settings for the wiimote") );
|
||||
PARAM_PREFIX FloatUserConfigParam m_wiimote_max
|
||||
PARAM_DEFAULT( FloatUserConfigParam(90.0f, "wiimote-max",
|
||||
PARAM_PREFIX FloatUserConfigParam m_wiimote_raw_max
|
||||
PARAM_DEFAULT( FloatUserConfigParam(25.0f, "wiimote-raw-max",
|
||||
&m_wiimote_group,
|
||||
"At what angle (0-128) maximum steering is reached.") );
|
||||
"At what raw input value maximum steering is reached (between 1 and 25).") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_wiimote_weight_linear
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.2f, "wiimote-weight-linear",
|
||||
@ -701,6 +699,8 @@ private:
|
||||
std::string m_filename;
|
||||
irr::core::stringw m_warning;
|
||||
|
||||
static const int m_current_config_version;
|
||||
|
||||
public:
|
||||
/** Create the user config object; does not actually load it,
|
||||
* UserConfig::loadConfig needs to be called. */
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <IParticleSystemSceneNode.h>
|
||||
#include <IParticleBoxEmitter.h>
|
||||
#include <ISceneManager.h>
|
||||
#include <algorithm>
|
||||
|
||||
class FadeAwayAffector : public scene::IParticleAffector
|
||||
{
|
||||
|
@ -60,11 +60,8 @@ int atoi_p(const char* val)
|
||||
bool LayoutManager::convertToCoord(std::string& x, int* absolute /* out */, int* percentage /* out */)
|
||||
{
|
||||
bool is_number;
|
||||
int i;
|
||||
std::istringstream myStream(x);
|
||||
is_number = (myStream >> i)!=0;
|
||||
|
||||
if(!is_number) return false;
|
||||
int i = 0;
|
||||
if (!StringUtils::fromString<int>(x, i /* out */)) return false;
|
||||
|
||||
if( x[x.size()-1] == '%' ) // percentage
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/bubble_widget.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
#include <IGUIStaticText.h>
|
||||
#include <IGUIElement.h>
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <IGUIEnvironment.h>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace GUIEngine;
|
||||
using namespace irr::core;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/model_view_widget.hpp"
|
||||
#include <algorithm>
|
||||
using namespace GUIEngine;
|
||||
using namespace irr::core;
|
||||
using namespace irr::gui;
|
||||
|
@ -64,7 +64,8 @@ void SpinnerWidget::add()
|
||||
{
|
||||
int i;
|
||||
std::istringstream myStream(min_s);
|
||||
bool is_number = (myStream >> i)!=0;
|
||||
myStream >> i;
|
||||
bool is_number = (i!=0);
|
||||
if (is_number)
|
||||
{
|
||||
m_min = i;
|
||||
@ -79,7 +80,8 @@ void SpinnerWidget::add()
|
||||
{
|
||||
int i;
|
||||
std::istringstream myStream(max_s);
|
||||
bool is_number = (myStream >> i)!=0;
|
||||
myStream >> i;
|
||||
bool is_number = (i!=0);
|
||||
if (is_number)
|
||||
{
|
||||
m_max = i;
|
||||
|
@ -76,24 +76,26 @@ void Wiimote::resetIrrEvent()
|
||||
*/
|
||||
void Wiimote::update()
|
||||
{
|
||||
float normalized_angle = -(m_wiimote_handle->accel.y-128)
|
||||
/ UserConfigParams::m_wiimote_raw_max;
|
||||
|
||||
#ifdef DEBUG
|
||||
if(UserConfigParams::m_wiimote_debug)
|
||||
{
|
||||
Log::verbose("wiimote", "pitch: %f yaw %f roll %f",
|
||||
m_wiimote_handle->orient.pitch,
|
||||
m_wiimote_handle->orient.yaw,
|
||||
m_wiimote_handle->orient.roll);
|
||||
Log::verbose("wiimote", "xyz %d %d %d %f",
|
||||
m_wiimote_handle->accel.x,
|
||||
m_wiimote_handle->accel.y,
|
||||
m_wiimote_handle->accel.z,
|
||||
normalized_angle);
|
||||
}
|
||||
#endif
|
||||
|
||||
float normalized_angle = -m_wiimote_handle->orient.pitch / UserConfigParams::m_wiimote_max;
|
||||
if(normalized_angle<-1.0f)
|
||||
normalized_angle = -1.0f;
|
||||
else if(normalized_angle>1.0f)
|
||||
normalized_angle = 1.0f;
|
||||
|
||||
// Shape the curve that determines steering depending on wiimote angle.
|
||||
// The wiimote value is already normalized to be in [-1,1]. Now use a
|
||||
// Shape the curve that determines steering depending on wiimote angle.
|
||||
// The wiimote value is already normalized to be in [-1,1]. Now use a
|
||||
// weighted linear combination to compute the steering value used in game.
|
||||
float w1 = UserConfigParams::m_wiimote_weight_linear;
|
||||
float w2 = UserConfigParams::m_wiimote_weight_square;
|
||||
|
@ -21,6 +21,14 @@
|
||||
|
||||
#include "karts/controller/battle_ai.hpp"
|
||||
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/controller/kart_control.hpp"
|
||||
#include "karts/controller/ai_properties.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/max_speed.hpp"
|
||||
#include "karts/rescue_animation.hpp"
|
||||
#include "karts/skidding.hpp"
|
||||
#include "karts/skidding_properties.hpp"
|
||||
#include "modes/three_strikes_battle.hpp"
|
||||
|
||||
|
||||
@ -43,7 +51,14 @@ BattleAI::BattleAI(AbstractKart *kart,
|
||||
m_track = NULL;
|
||||
}
|
||||
// Don't call our own setControllerName, since this will add a
|
||||
// billboard showing 'AIBaseLapController' to the kar.
|
||||
// billboard showing 'AIBaseController' to the kar.
|
||||
Controller::setControllerName("BattleAI");
|
||||
|
||||
}
|
||||
|
||||
void BattleAI::update(float dt)
|
||||
{
|
||||
m_controls->m_accel = 1;
|
||||
m_controls->m_steer = 0;
|
||||
return;
|
||||
}
|
@ -54,7 +54,7 @@ public:
|
||||
BattleAI(AbstractKart *kart,
|
||||
StateManager::ActivePlayer *player=NULL);
|
||||
//~BattleAI();
|
||||
virtual void update (float delta) {};
|
||||
virtual void update (float delta);
|
||||
virtual void reset () {};
|
||||
//static void enableDebug() {m_ai_debug = true; }
|
||||
virtual void crashed(const AbstractKart *k) {};
|
||||
|
@ -57,10 +57,12 @@ void ThreeStrikesBattle::init()
|
||||
m_display_rank = false;
|
||||
|
||||
// check for possible problems if AI karts were incorrectly added
|
||||
if(getNumKarts() > race_manager->getNumPlayers())
|
||||
// FIXME : remove this bit of code in future since ai will be added
|
||||
/* if(getNumKarts() > race_manager->getNumPlayers())
|
||||
{
|
||||
Log::fatal("Three Strikes Battle", "No AI exists for this game mode");
|
||||
}
|
||||
*/
|
||||
m_kart_info.resize(m_karts.size());
|
||||
} // ThreeStrikesBattle
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/credits.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "irrString.h"
|
||||
using irr::core::stringw;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <map>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace tinygettext {
|
||||
|
||||
|
@ -605,7 +605,7 @@ void QuadGraph::computeDistanceFromStart(unsigned int node, float new_distance)
|
||||
if(current_distance<new_distance)
|
||||
{
|
||||
float delta = new_distance - current_distance;
|
||||
updateDistancesForAllSuccessors(gn->getQuadIndex(), delta);
|
||||
updateDistancesForAllSuccessors(gn->getQuadIndex(), delta, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -634,9 +634,21 @@ void QuadGraph::computeDistanceFromStart(unsigned int node, float new_distance)
|
||||
* distance from start.
|
||||
* \param indx Index of the node for which to increase the distance.
|
||||
* \param delta Amount by which to increase the distance.
|
||||
* \param recursive_count Counts how often this function was called
|
||||
* recursively in order to catch incorrect graphs that contain loops.
|
||||
*/
|
||||
void QuadGraph::updateDistancesForAllSuccessors(unsigned int indx, float delta)
|
||||
void QuadGraph::updateDistancesForAllSuccessors(unsigned int indx, float delta,
|
||||
unsigned int recursive_count)
|
||||
{
|
||||
if(recursive_count>getNumNodes())
|
||||
{
|
||||
Log::error("QuadGraph",
|
||||
"Quad graph contains a loop (without start node).");
|
||||
Log::fatal("QuadGraph",
|
||||
"Fix graph, check for directions of all shortcuts etc.");
|
||||
}
|
||||
recursive_count++;
|
||||
|
||||
GraphNode &g=getNode(indx);
|
||||
g.setDistanceFromStart(g.getDistanceFromStart()+delta);
|
||||
for(unsigned int i=0; i<g.getNumberOfSuccessors(); i++)
|
||||
@ -653,7 +665,8 @@ void QuadGraph::updateDistancesForAllSuccessors(unsigned int indx, float delta)
|
||||
if(g.getDistanceFromStart()+g.getDistanceToSuccessor(i) >
|
||||
g_next.getDistanceFromStart())
|
||||
{
|
||||
updateDistancesForAllSuccessors(g.getSuccessor(i), delta);
|
||||
updateDistancesForAllSuccessors(g.getSuccessor(i), delta,
|
||||
recursive_count);
|
||||
}
|
||||
}
|
||||
} // updateDistancesForAllSuccessors
|
||||
|
@ -123,7 +123,9 @@ public:
|
||||
const video::SColor &fill_color
|
||||
=video::SColor(127, 255, 255, 255) );
|
||||
void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *out) const;
|
||||
void updateDistancesForAllSuccessors(unsigned int indx, float delta);
|
||||
void updateDistancesForAllSuccessors(unsigned int indx,
|
||||
float delta,
|
||||
unsigned int count);
|
||||
void setupPaths();
|
||||
void computeChecklineRequirements();
|
||||
// ----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user