diff --git a/data/items/banana.b3d b/data/items/banana.b3d new file mode 100755 index 000000000..a15413adc Binary files /dev/null and b/data/items/banana.b3d differ diff --git a/data/items/banana.png b/data/items/banana.png new file mode 100644 index 000000000..3ddc4e67f Binary files /dev/null and b/data/items/banana.png differ diff --git a/data/items/gift-box.ac b/data/items/gift-box.ac index 78c0b8fdc..988c0ee63 100644 --- a/data/items/gift-box.ac +++ b/data/items/gift-box.ac @@ -9,7 +9,7 @@ OBJECT poly name "GiftBox_0" data 7 GiftBox -texture "gift-loop.rgb" +texture "gift-loop.png" texrep 1 1 crease 70.000000 numvert 158 @@ -1188,7 +1188,7 @@ OBJECT poly name "GiftBox_1" data 7 GiftBox -texture "gift-box.rgb" +texture "gift-box.png" texrep 1 1 crease 70.000000 numvert 28 diff --git a/data/items/gift-box.b3d b/data/items/gift-box.b3d new file mode 100755 index 000000000..9ed24bb25 Binary files /dev/null and b/data/items/gift-box.b3d differ diff --git a/data/items/gift-box.png b/data/items/gift-box.png new file mode 100644 index 000000000..5a9f7282b Binary files /dev/null and b/data/items/gift-box.png differ diff --git a/data/items/gift-loop.png b/data/items/gift-loop.png new file mode 100644 index 000000000..d09007a51 Binary files /dev/null and b/data/items/gift-loop.png differ diff --git a/data/items/nitro-tank.png b/data/items/nitro-tank.png new file mode 100644 index 000000000..03a4322f0 Binary files /dev/null and b/data/items/nitro-tank.png differ diff --git a/data/items/nitrotank-big.ac b/data/items/nitrotank-big.ac index 08ceec733..796ed1143 100644 --- a/data/items/nitrotank-big.ac +++ b/data/items/nitrotank-big.ac @@ -9,7 +9,7 @@ OBJECT poly name "BigTank_0" data 7 BigTank -texture "tank-blue.rgb" +texture "tank-blue.png" texrep 1 1 crease 70.000000 numvert 37 @@ -434,7 +434,7 @@ OBJECT poly name "BigTank_1" data 7 BigTank -texture "nitro-tank.rgb" +texture "nitro-tank.png" texrep 1 1 crease 70.000000 numvert 67 @@ -999,7 +999,7 @@ OBJECT poly name "BigTank_2" data 7 BigTank -texture "tank-green.rgb" +texture "tank-green.png" texrep 1 1 crease 70.000000 numvert 46 diff --git a/data/items/nitrotank-big.b3d b/data/items/nitrotank-big.b3d new file mode 100755 index 000000000..8c1f71384 Binary files /dev/null and b/data/items/nitrotank-big.b3d differ diff --git a/data/items/nitrotank-small.ac b/data/items/nitrotank-small.ac index 51a285a94..c34eab8e0 100644 --- a/data/items/nitrotank-small.ac +++ b/data/items/nitrotank-small.ac @@ -9,7 +9,7 @@ OBJECT poly name "SmallTank_0" data 9 SmallTank -texture "nitro-tank.rgb" +texture "nitro-tank.png" texrep 1 1 crease 70.000000 numvert 59 @@ -558,7 +558,7 @@ OBJECT poly name "SmallTank_1" data 9 SmallTank -texture "tank-cyan.rgb" +texture "tank-cyan.png" texrep 1 1 crease 70.000000 numvert 46 @@ -1100,7 +1100,7 @@ OBJECT poly name "SmallTank_2" data 9 SmallTank -texture "tank-blue.rgb" +texture "tank-blue.png" texrep 1 1 crease 70.000000 numvert 37 diff --git a/data/items/nitrotank-small.b3d b/data/items/nitrotank-small.b3d new file mode 100755 index 000000000..1b0a32036 Binary files /dev/null and b/data/items/nitrotank-small.b3d differ diff --git a/data/items/tank-blue.png b/data/items/tank-blue.png new file mode 100644 index 000000000..0ab0eb070 Binary files /dev/null and b/data/items/tank-blue.png differ diff --git a/data/items/tank-cyan.png b/data/items/tank-cyan.png new file mode 100644 index 000000000..85e4bd5a3 Binary files /dev/null and b/data/items/tank-cyan.png differ diff --git a/data/items/tank-green.png b/data/items/tank-green.png new file mode 100644 index 000000000..bbc74a78b Binary files /dev/null and b/data/items/tank-green.png differ diff --git a/data/models/bowling.b3d b/data/models/bowling.b3d new file mode 100755 index 000000000..9be533304 Binary files /dev/null and b/data/models/bowling.b3d differ diff --git a/data/models/bowling.png b/data/models/bowling.png new file mode 100644 index 000000000..5214fb87f Binary files /dev/null and b/data/models/bowling.png differ diff --git a/src/explosion.cpp b/src/explosion.cpp index 420771bac..061542228 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -17,21 +17,17 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include #include "explosion.hpp" + #include "items/projectile_manager.hpp" #include "audio/sfx_base.hpp" #include "audio/sfx_manager.hpp" #include "graphics/scene.hpp" #include "utils/vec3.hpp" -Explosion::Explosion(const Vec3& coord, const int explosion_sound) : ssgTransform() +Explosion::Explosion(const Vec3& coord, const int explosion_sound) { - this->ref(); - ssgCutout *cut = new ssgCutout(); - addKid(cut); // derefing the explosion will free the cutout - m_seq = projectile_manager->getExplosionModel(); - cut->addKid(m_seq); + m_mesh = projectile_manager->getExplosionModel(); m_explode_sound = sfx_manager->newSFX( (SFXManager::SFXType)explosion_sound ); init(coord); } // Explosion @@ -54,15 +50,16 @@ void Explosion::init(const Vec3& coord) sgCoord c; c.xyz[0]=coord[0];c.xyz[1]=coord[1];c.xyz[2]=coord[2]; c.hpr[0]=0; c.hpr[1]=0; c.hpr[2]=0; - setTransform(&c); + //setTransform(&c); m_step = -1; - stk_scene->add(this); + //stk_scene->add(this); m_has_ended = false; } //----------------------------------------------------------------------------- void Explosion::update(float dt) { +#ifndef HAVE_IRRLICHT //fprintf(stderr, "Explosion: update: "); if(++m_step >= m_seq->getNumKids()) { @@ -85,4 +82,5 @@ void Explosion::update(float dt) //fprintf(stderr, "Step.\n"); m_seq->selectStep(m_step); } +#endif } diff --git a/src/explosion.hpp b/src/explosion.hpp index 48b357dc0..0ce601a6c 100644 --- a/src/explosion.hpp +++ b/src/explosion.hpp @@ -17,23 +17,30 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HEADER_EXPLOSION_H -#define HEADER_EXPLOSION_H - -#include +#ifndef HEADER_EXPLOSION_HPP +#define HEADER_EXPLOSION_HPP class Vec3; class SFXBase; +namespace irr +{ + namespace scene + { + class IMesh; + class ISceneNode; + } +} -class Explosion : public ssgTransform +class Explosion { private: - SFXBase* m_explode_sound; - bool m_has_ended; + SFXBase* m_explode_sound; + bool m_has_ended; + irr::scene::IMesh *m_mesh; + irr::scene::ISceneNode *m_node; public: int m_step ; - ssgSelector *m_seq ; Explosion(const Vec3& coord, const int explosion_sound); ~Explosion(); diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp index 2674963d5..9be052e41 100644 --- a/src/io/file_manager.cpp +++ b/src/io/file_manager.cpp @@ -196,6 +196,7 @@ FileManager::~FileManager() XMLReader *FileManager::getXMLReader(const std::string &f) { io::IXMLReader *r = m_file_system->createXMLReader(f.c_str()); + if(!r) return NULL; return new XMLReader(r); } // getXMLReader diff --git a/src/io/xml_node.cpp b/src/io/xml_node.cpp index 7f2da61cd..1b439d0a3 100644 --- a/src/io/xml_node.cpp +++ b/src/io/xml_node.cpp @@ -113,7 +113,7 @@ int XMLNode::get(const std::string &attribute, bool *value) const { std::string s; if(!get(attribute, &s)) return 0; - *value = s=="" || s[0]=='T' || s[0]=='t' || + *value = s=="" || s[0]=='T' || s[0]=='t' || s[0]=='Y' || s[0]=='y' || s=="true" || s=="TRUE" || s=="#t" || s=="#T"; return 1; } // get(bool) diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp index 57f9d10e5..73ce1e8b1 100644 --- a/src/items/item_manager.cpp +++ b/src/items/item_manager.cpp @@ -73,26 +73,21 @@ Shadow::Shadow ( float x1, float x2, float y1, float y2 ) ssgVtxTable *gs = new ssgVtxTable ( GL_TRIANGLE_STRIP, va, na, ta, ca ) ; gs -> clrTraversalMaskBits ( SSGTRAV_ISECT|SSGTRAV_HOT ) ; +#ifndef HAVE_IRRLICHT gs -> setState ( fuzzy_gst ) ; +#endif sh -> addKid ( gs ) ; sh -> ref () ; /* Make sure it doesn't get deleted by mistake */ } // Shadow //============================================================================= ItemManager* item_manager; -#ifdef HAVE_IRRLICHT + typedef std::map::const_iterator CI_type; -#else -typedef std::map::const_iterator CI_type; -#endif ItemManager::ItemManager() { -#ifdef HAVE_IRRLICHT m_all_meshes.clear(); -#else - m_all_models.clear(); -#endif // The actual loading is done in loadDefaultItems } // ItemManager @@ -106,26 +101,17 @@ void ItemManager::removeTextures() } m_all_items.clear(); -#ifdef HAVE_IRRLICHT for(CI_type i=m_all_meshes.begin(); i!=m_all_meshes.end(); ++i) { i->second->drop(); } m_all_meshes.clear(); -#else - for(CI_type i=m_all_models.begin(); i!=m_all_models.end(); ++i) - { - i->second->deRef(); - } - m_all_models.clear(); -#endif callback_manager->clear(CB_ITEM); } // removeTextures //----------------------------------------------------------------------------- ItemManager::~ItemManager() { -#ifdef HAVE_IRRLICHT for(CI_type i=m_all_meshes.begin(); i!=m_all_meshes.end(); ++i) { // FIXME: What about this plib comment: @@ -135,16 +121,6 @@ ItemManager::~ItemManager() i->second->drop(); } m_all_meshes.clear(); -#else - for(CI_type i=m_all_models.begin(); i!=m_all_models.end(); ++i) - { - // We can't use ssgDeRefDelete here, since then the object would be - // freed, and when m_all_models is deleted, we have invalid memory - // accesses. - i->second->deRef(); - } - m_all_models.clear(); -#endif } // ~ItemManager //----------------------------------------------------------------------------- @@ -160,7 +136,6 @@ void ItemManager::loadDefaultItems() for(std::set::iterator i = files.begin(); i != files.end(); ++i) { -#ifdef HAVE_IRRLICHT // FIXME: We should try to check the extension, // i.e. load only .3ds files scene::IMesh *mesh = irr_driver->getAnimatedMesh(*i); @@ -168,16 +143,6 @@ void ItemManager::loadDefaultItems() std::string shortName = StringUtils::basename(StringUtils::without_extension(*i)); m_all_meshes[shortName] = mesh; mesh->grab(); -#else - if(!StringUtils::has_suffix(*i, ".ac")) continue; - ssgEntity* h = loader->load(*i, CB_ITEM, - /*optimise*/true, - /*full_path*/true); - std::string shortName = StringUtils::basename(StringUtils::without_extension(*i)); - h->ref(); - h->setName(shortName.c_str()); - m_all_models[shortName] = h; -#endif } // for i setDefaultItemStyle(); @@ -198,13 +163,8 @@ void ItemManager::setDefaultItemStyle() std::ostringstream msg; for(int i=Item::ITEM_FIRST; i<=Item::ITEM_LAST; i++) { -#ifdef HAVE_IRRLICHT m_item_mesh[i] = m_all_meshes[DEFAULT_NAMES[i]]; if(!m_item_mesh[i]) -#else - m_item_model[i] = m_all_models[DEFAULT_NAMES[i]]; - if(!m_item_model[i]) -#endif { msg << "Item model '" << DEFAULT_NAMES[i] << "' is missing (see item_manager)!\n"; @@ -215,11 +175,7 @@ void ItemManager::setDefaultItemStyle() if(bError) { fprintf(stderr, "The following models are available:\n"); -#ifdef HAVE_IRRLICHT for(CI_type i=m_all_meshes.begin(); i!=m_all_meshes.end(); ++i) -#else - for(CI_type i=m_all_models.begin(); i!=m_all_models.end(); ++i) -#endif { if(i->second) { @@ -242,21 +198,12 @@ Item* ItemManager::newItem(Item::ItemType type, const Vec3& xyz, const Vec3 &normal, Kart *parent) { Item* h; -#ifdef HAVE_IRRLICHT if(type == Item::ITEM_BUBBLEGUM) h = new BubbleGumItem(type, xyz, normal, m_item_mesh[type], m_all_items.size()); else h = new Item(type, xyz, normal, m_item_mesh[type], m_all_items.size()); -#else - if(type == Item::ITEM_BUBBLEGUM) - h = new BubbleGumItem(type, xyz, normal, m_item_model[type], - m_all_items.size()); - else - h = new Item(type, xyz, normal, m_item_model[type], - m_all_items.size()); -#endif if(parent != NULL) h->setParent(parent); m_all_items.push_back(h); @@ -409,10 +356,6 @@ void ItemManager::setItem(const lisp::Lisp *item_node, item_node->get(colour, name); if(name.size()>0) { -#ifdef HAVE_IRRLICHT m_item_mesh[type]=m_all_meshes[name]; -#else - m_item_model[type]=m_all_models[name]; -#endif } } // setItem diff --git a/src/items/powerup_manager.cpp b/src/items/powerup_manager.cpp index ed690a980..3605b2bc9 100644 --- a/src/items/powerup_manager.cpp +++ b/src/items/powerup_manager.cpp @@ -42,7 +42,6 @@ initPowerupType; initPowerupType ict[]= { -#ifdef HAVE_IRRLICHT {POWERUP_ZIPPER, "zipper.collectable" }, {POWERUP_BOWLING, "bowling.projectile" }, {POWERUP_BUBBLEGUM, "bubblegum.xml" }, @@ -51,16 +50,6 @@ initPowerupType ict[]= {POWERUP_PARACHUTE, "parachute.collectable" }, {POWERUP_PLUNGER, "plunger.projectile" }, {POWERUP_MAX, "" }, -#else - {POWERUP_ZIPPER, "zipper.collectable" }, - {POWERUP_BOWLING, "bowling.projectile" }, - {POWERUP_BUBBLEGUM, "bubblegum.projectile" }, - {POWERUP_CAKE, "cake.projectile" }, - {POWERUP_ANVIL, "anvil.collectable" }, - {POWERUP_PARACHUTE, "parachute.collectable" }, - {POWERUP_PLUNGER, "plunger.projectile" }, - {POWERUP_MAX, "" }, -#endif }; PowerupManager* powerup_manager=0; @@ -70,11 +59,7 @@ PowerupManager::PowerupManager() { for(int i=0; iget("name", sName ); -#ifdef HAVE_IRRLICHT lisp->get("mesh", sModel ); -#else - lisp->get("model", sModel ); -#endif lisp->get("icon", sIconFile ); // load material m_all_icons[collectType] = material_manager->getMaterial(sIconFile, /* full_path */ false, /*make_permanent */ true); -#ifdef HAVE_IRRLICHT if(sModel!="") { // FIXME LEAK: not freed (unimportant, since the models have to exist @@ -153,27 +133,8 @@ void PowerupManager::LoadNode(const lisp::Lisp* lisp, int collectType ) m_all_meshes[collectType] = 0; m_all_extends[collectType] = btVector3(0.0f,0.0f,0.0f); } -#else - m_all_icons[collectType]->getState()->ref(); - - if(sModel!="") - { - // FIXME LEAK: not freed (unimportant, since the models have to exist - // for the whole game anyway). - ssgEntity* e = loader->load(sModel, CB_COLLECTABLE); - m_all_models[collectType] = e; - e->ref(); - e->clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT); - } - else - { - m_all_models[collectType] = 0; - m_all_extends[collectType] = btVector3(0.0f,0.0f,0.0f); - } -#endif // Load special attributes for certain powerups -#ifdef HAVE_IRRLICHT switch (collectType) { case POWERUP_BOWLING: Bowling::init(lisp, m_all_meshes[collectType]); break; @@ -183,16 +144,5 @@ void PowerupManager::LoadNode(const lisp::Lisp* lisp, int collectType ) Cake::init(lisp, m_all_meshes[collectType]); break; default:; } // switch -#else - switch (collectType) { - case POWERUP_BOWLING: - Bowling::init (lisp, m_all_models[collectType]); break; - case POWERUP_PLUNGER: - Plunger::init (lisp, m_all_models[collectType]); break; - case POWERUP_CAKE: - Cake::init (lisp, m_all_models[collectType]); break; - default:; - } // switch -#endif } // LoadNode diff --git a/src/items/powerup_manager.hpp b/src/items/powerup_manager.hpp index 8a5fffe11..478592f02 100644 --- a/src/items/powerup_manager.hpp +++ b/src/items/powerup_manager.hpp @@ -20,17 +20,13 @@ #ifndef HEADER_POWERUPMANAGER_HPP #define HEADER_POWERUPMANAGER_HPP -#ifdef HAVE_IRRLICHT #include "irrlicht.h" -#endif + #include "lisp/parser.hpp" #include "lisp/lisp.hpp" #include "btBulletDynamicsCommon.h" class Material; -#ifndef HAVE_IRRLICHT -class ssgEntity; -#endif // The anvil and parachute must be at the end of the enum, and the // zipper just before them (see Powerup::hitBonusBox). @@ -48,11 +44,7 @@ protected: float m_all_force_to_target[POWERUP_MAX]; // apply this force to move towards // the target float m_all_max_turn_angle[POWERUP_MAX]; // maximum turn angle for homing -#ifdef HAVE_IRRLICHT scene::IMesh *m_all_meshes[POWERUP_MAX]; -#else - ssgEntity* m_all_models[POWERUP_MAX]; -#endif btVector3 m_all_extends[POWERUP_MAX]; void LoadNode (const lisp::Lisp* lisp, int collectType); public: @@ -61,13 +53,9 @@ public: void removeTextures (); void Load (int collectType, const char* filename); Material* getIcon (int type) const {return m_all_icons [type]; } -#ifdef HAVE_IRRLICHT /** Returns the mesh for a certain powerup. * \param type Mesh type for which the model is returned. */ scene::IMesh *getMesh (int type) const {return m_all_meshes[type]; } -#else - ssgEntity* getModel (int type) const {return m_all_models[type]; } -#endif float getForceToTarget(int type) const {return m_all_force_to_target[type]; } float getMaxDistance (int type) const {return m_all_max_distance[type];} float getMaxTurnAngle (int type) const {return m_all_max_turn_angle[type];} diff --git a/src/items/projectile_manager.cpp b/src/items/projectile_manager.cpp index 91de59bdd..ab69e4dcd 100644 --- a/src/items/projectile_manager.cpp +++ b/src/items/projectile_manager.cpp @@ -54,7 +54,7 @@ void ProjectileManager::loadData() void ProjectileManager::removeTextures() { cleanup(); - ssgDeRefDelete(m_explosion_model); + //ssgDeRefDelete(m_explosion_model); // Only the explosion is here, all other models are actually managed // by powerup_manager. callback_manager->clear(CB_EXPLOSION); @@ -78,7 +78,7 @@ void ProjectileManager::cleanup() i != m_active_explosions.end(); ++i) { stk_scene->remove((ssgTransform*)*i); - ssgDeRefDelete(*i); + //ssgDeRefDelete(*i); } m_active_explosions.clear(); } // cleanup @@ -129,7 +129,7 @@ void ProjectileManager::update(float dt) if(!(*e)->hasEnded()) { e++; continue;} Explosion *exp=*e; Explosions::iterator eNext=m_active_explosions.erase(e); - ssgDeRefDelete(exp); // reduce refcount and free object + //ssgDeRefDelete(exp); // reduce refcount and free object e=eNext; } // while e!=m_active_explosions.end() } // if m_explosion_ended diff --git a/src/items/projectile_manager.hpp b/src/items/projectile_manager.hpp index 9f15dd2b5..4a6f98897 100644 --- a/src/items/projectile_manager.hpp +++ b/src/items/projectile_manager.hpp @@ -17,13 +17,14 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HEADER_PROJECTILEMANAGER_H -#define HEADER_PROJECTILEMANAGER_H +#ifndef HEADER_PROJECTILEMANAGER_HPP +#define HEADER_PROJECTILEMANAGER_HPP #include -#include -#include "items/powerup_manager.hpp" +#include "irrlicht.h" + #include "audio/sfx_manager.hpp" +#include "items/powerup_manager.hpp" class Vec3; class Kart; @@ -44,7 +45,7 @@ private: // being shown Explosions m_active_explosions; - ssgSelector* m_explosion_model; + scene::IMesh *m_explosion_model; bool m_something_was_hit; bool m_explosion_ended; void updateClient(float dt); @@ -55,9 +56,9 @@ public: /** Notifies the projectile manager that something needs to be removed. */ void notifyRemove () {m_something_was_hit=true; } void FinishedExplosion() {m_explosion_ended =true; } - ssgSelector* getExplosionModel() + scene::IMesh* getExplosionModel() { - return (ssgSelector*)m_explosion_model->clone(); + return m_explosion_model; } unsigned int getNumProjectiles() const {return m_active_explosions.size();} int getProjectileId (const std::string ident); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 356c26c2d..9cc908c1f 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -127,7 +127,7 @@ void KartProperties::load(const std::string &filename, const std::string &node, // Load material - std::string materials_file = file_manager->getKartFile("materials.dat",getIdent()); + std::string materials_file = file_manager->getKartFile("materials.xml",getIdent()); file_manager->pushModelSearchPath(file_manager->getKartFile("", getIdent())); file_manager->pushTextureSearchPath(file_manager->getKartFile("", getIdent())); diff --git a/src/material.cpp b/src/material.cpp index f160429d8..b84381ed2 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -30,74 +30,15 @@ #define UCLAMP 1 #define VCLAMP 2 -#ifndef HAVE_IRRLICHT -int clearSpheremap ( ssgEntity * ) -{ - glDisable ( GL_TEXTURE_GEN_S ) ; - glDisable ( GL_TEXTURE_GEN_T ) ; - return true ; -} // clearSpheremap - -//============================================================================= -int setSpheremap ( ssgEntity * ) -{ - glTexGeni ( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ) ; - glTexGeni ( GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ) ; - glEnable ( GL_TEXTURE_GEN_S ) ; - glEnable ( GL_TEXTURE_GEN_T ) ; - return true ; -} // setSpheremap -#endif - -//============================================================================= -#ifndef HAVE_IRRLICHT -bool Material::parseBool ( char **p ) -{ - /* Skip leading spaces */ - - while ( **p <= ' ' && **p != '\0' ) (*p)++ ; - - const bool RES = ( ( **p == 'Y' ) || ( **p == 'y' ) ) ; - - while ( **p > ' ' && **p != '\0' ) (*p)++ ; - - return RES ; -} // parseBool - -//----------------------------------------------------------------------------- -int Material::parseInt ( char **p ) -{ - /* Skip leading spaces */ - - while ( **p <= ' ' && **p != '\0' ) (*p)++ ; - - return strtol ( *p, p, 0 ) ; -} // parseInt - -//----------------------------------------------------------------------------- -float Material::parseFloat ( char **p ) -{ - /* Skip leading spaces */ - - while ( **p <= ' ' && **p != '\0' ) (*p)++ ; - - return (float)strtod ( *p, p ) ; -} // parseFloat -#endif //----------------------------------------------------------------------------- Material::Material(unsigned int index) { m_texname = ""; -#ifndef HAVE_IRRLICHT - m_predraw = m_postdraw = NULL ; -#endif - init (index); install(); } // Material //----------------------------------------------------------------------------- -#ifdef HAVE_IRRLICHT /** Create a new material using the parameters specified in the xml file. * \param node Node containing the parameters for this material. * \param index Index in material_manager. @@ -142,41 +83,6 @@ Material::Material(const std::string& fname, int index, bool is_full_path) install(is_full_path); } // Material -#else -Material::Material(const std::string& fname, char *description, - int index, bool is_full_path) -{ - m_texname = fname; - m_predraw = m_postdraw = NULL ; - - init (index); - - if(strlen(description)>0) - { - m_clamp_tex = parseBool (&description) ? UCLAMP : 0 ; - m_clamp_tex += parseBool (&description) ? VCLAMP : 0 ; - - m_transparency = parseBool (&description); - m_alpha_ref = parseFloat(&description); - m_lighting = parseBool (&description); - m_sphere_map = parseBool (&description); - m_friction = parseFloat(&description); - m_ignore = parseBool (&description); - m_zipper = parseBool (&description); - m_resetter = parseBool (&description); - m_collideable = parseBool (&description); - m_max_speed_fraction = parseFloat(&description); - m_slowdown = parseFloat(&description); - // Set the optional parameters. - if(m_max_speed_fraction <= 0.0f) - m_max_speed_fraction = 1.0f; - if(m_slowdown <= 0.0f) - m_slowdown = stk_config->m_slowdown_factor; - } - install(is_full_path); -} // Material -#endif - //----------------------------------------------------------------------------- Material::~Material() { @@ -203,14 +109,6 @@ void Material::init(unsigned int index) m_slowdown = stk_config->m_slowdown_factor; } -//----------------------------------------------------------------------------- -#ifndef HAVE_IRRLICHT -void Material::applyToLeaf(ssgLeaf *l) -{ - if ( m_predraw ) l -> setCallback ( SSG_CALLBACK_PREDRAW , m_predraw ) ; - if ( m_postdraw ) l -> setCallback ( SSG_CALLBACK_POSTDRAW, m_postdraw ) ; -} // applyToLeaf -#endif //----------------------------------------------------------------------------- void Material::install(bool is_full_path) { diff --git a/src/material.hpp b/src/material.hpp index d3798ab4b..5653483ec 100644 --- a/src/material.hpp +++ b/src/material.hpp @@ -22,25 +22,15 @@ #include #define _WINSOCKAPI_ -#ifdef HAVE_IRRLICHT #include "irrlicht.h" using namespace irr; -#else -#include -#endif class XMLNode; class Material { private: -#ifdef HAVE_IRRLICHT video::ITexture *m_texture; -#else - ssgSimpleState *m_state; - ssgCallback m_predraw; - ssgCallback m_postdraw; -#endif unsigned int m_index; std::string m_texname; bool m_collideable; @@ -57,35 +47,20 @@ private: float m_slowdown; /** Maximum speed at which no more slow down occurs. */ float m_max_speed_fraction; -#ifndef HAVE_IRRLICHT - bool parseBool ( char **p ); - int parseInt ( char **p ); - float parseFloat ( char **p ); -#endif void init (unsigned int index); void install (bool is_full_path=false); public: Material(unsigned int index); -#ifdef HAVE_IRRLICHT Material(const XMLNode *node, int index); Material(const std::string& fname, int index, bool is_full_path=false); -#else - Material(const std::string& fname, char *description, int index, - bool is_full_path=false); -#endif ~Material (); int matches ( char *tx ) ; -#ifdef HAVE_IRRLICHT /** Returns the ITexture associated with this material. */ video::ITexture *getTexture() const { return m_texture; } -#else - ssgSimpleState - *getState () const { return m_state ; } -#endif bool isIgnore () const { return m_ignore; } bool isZipper () const { return m_zipper; } bool isSphereMap () const { return m_sphere_map; } @@ -100,12 +75,6 @@ public: /** Returns the slowdown that happens if a kart is * faster than the maximum speed. */ float getSlowDown () const { return m_slowdown; } -#ifndef HAVE_IRRLICHT - void apply () { m_state ->apply(); } - void force () { m_state ->force(); } - void applyToLeaf ( ssgLeaf *l ) ; -#endif - } ; diff --git a/src/material_manager.cpp b/src/material_manager.cpp index fcc53796b..26a474e98 100644 --- a/src/material_manager.cpp +++ b/src/material_manager.cpp @@ -70,17 +70,9 @@ void MaterialManager::loadMaterial() // Use temp material for reading, but then set the shared // material index later, so that these materials are not popped -#ifdef HAVE_IRRLICHT const std::string fname = "materials.xml"; -#else - const std::string fname = "materials.dat"; -#endif std::string full_name = file_manager->getTextureFile(fname); addSharedMaterial(full_name); -#ifndef HAVE_IRRLICHT - ssgSetAppStateCallback(getAppState); - fuzzy_gst = getMaterial("fuzzy.rgb")->getState(); -#endif // Save index of shared textures m_shared_material_index = (int)m_materials.size(); } // MaterialManager @@ -108,8 +100,8 @@ void MaterialManager::addSharedMaterial(const std::string& filename) //----------------------------------------------------------------------------- bool MaterialManager::pushTempMaterial(const std::string& filename) { -#ifdef HAVE_IRRLICHT XMLReader *xml = file_manager->getXMLReader(filename); + if(!xml) return true; for(unsigned int i=0; igetNumNodes(); i++) { const XMLNode *node = xml->getNode(i); @@ -130,17 +122,6 @@ bool MaterialManager::pushTempMaterial(const std::string& filename) } } // for igetNumNodes)( return true; -#else - FILE *fd = fopen(filename.c_str(), "r" ); - - if ( fd == NULL ) return false; - - while ( parseMaterial ( fd ) ) - /* Read file */ ; - - fclose ( fd ) ; - return true; -#endif } // pushTempMaterial //----------------------------------------------------------------------------- @@ -153,71 +134,6 @@ void MaterialManager::popTempMaterial() } // for i } // popTempMaterial -//----------------------------------------------------------------------------- -#ifndef HAVE_IRRLICHT -char* MaterialManager::parseFileName(char **str) -{ - char *p = *str ; - - /* Skip leading spaces */ - while ( *p <= ' ' && *p != '\0' ) p++ ; - - /* Skip blank lines and comments */ - if ( *p == '#' || *p == '\0' ) - return NULL ; - - if ( *p != '"' ) - { - fprintf(stderr, "ERROR: Material file entries must start with '\"'\n" - "ERROR: Offending line is '%s'\n", *str); - return NULL ; - } - - /* Filename? */ - char *f = ++p ; - while ( *p != '"' && *p != '\0' ) p++ ; - - if ( *p != '"' ) - { - fprintf(stderr, - "ERROR: Unterminated string constant '%s' in materials file.\n", *str ) ; - return NULL ; - } - - *p = '\0' ; - *str = ++p ; - - return f ; -} // parseFilename -#endif -//----------------------------------------------------------------------------- -#ifndef HAVE_IRRLICHT -int MaterialManager::parseMaterial ( FILE *fd ) -{ - char str [ 1024 ] ; - - while ( ! feof ( fd ) ) - { - char *s = str ; - - if ( fgets ( s, 1024, fd ) == NULL ) - return false ; - - s [ strlen(s) - 1 ] = '\0' ; - - char *f = parseFileName ( & s ) ; - - if ( f != NULL ) - { - m_materials.push_back(new Material (f, s, m_materials.size() )); - return true ; - } - } - - return false ; -} // parseMaterial -#endif - //----------------------------------------------------------------------------- Material *MaterialManager::getMaterial ( ssgLeaf *l ) { @@ -262,22 +178,9 @@ Material *MaterialManager::getMaterial(const std::string& fname, } // Add the new material -#ifdef HAVE_IRRLICHT Material* m=new Material(fname, m_materials.size(), is_full_path); -#else - Material* m=new Material(fname, "", m_materials.size(), is_full_path); -#endif m_materials.push_back(m); if(make_permanent) m_shared_material_index = (int)m_materials.size(); return m ; } // getMaterial -//============================================================================= -#ifndef HAVE_IRRLICHT -ssgState *getAppState ( char *fname ) -{ - Material *m = material_manager->getMaterial ( fname ) ; - return ( m == NULL ) ? NULL : m -> getState () ; -} // getAppState -#endif - diff --git a/src/material_manager.hpp b/src/material_manager.hpp index ea42c992d..babc50312 100644 --- a/src/material_manager.hpp +++ b/src/material_manager.hpp @@ -32,10 +32,6 @@ class MaterialManager { private: -#ifndef HAVE_IRRLICHT - char *parseFileName(char **str); - int parseMaterial(FILE *fd); -#endif void parseMaterialFile(const std::string& filename); int m_shared_material_index; @@ -53,10 +49,6 @@ public: void popTempMaterial (); }; -extern ssgState *fuzzy_gst;//, *herringbones_gst; -#ifndef HAVE_IRRLICHT -ssgState *getAppState ( char *fname ) ; -#endif extern MaterialManager *material_manager; #endif diff --git a/src/sdldrv.cpp b/src/sdldrv.cpp index 12148727d..fed7f94c4 100644 --- a/src/sdldrv.cpp +++ b/src/sdldrv.cpp @@ -59,11 +59,7 @@ SDLDriver::SDLDriver() : m_sensed_input(0), m_action_map(0), m_main_surface(0), m_flags(0), m_stick_infos(0), m_mode(BOOTSTRAP), m_mouse_val_x(0), m_mouse_val_y(0) { -#ifdef HAVE_IRRLICHT if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0) -#else - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0) -#endif { fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); exit(1); @@ -109,9 +105,6 @@ SDLDriver::SDLDriver() SDL_JoystickEventState(SDL_ENABLE); initStickInfos(); -#ifndef HAVE_IRRLICHT - SDL_WM_SetCaption("SuperTuxKart", NULL); -#endif // Get into menu mode initially. setMode(MENU); @@ -260,52 +253,6 @@ void SDLDriver::toggleFullscreen(bool resetTextures) */ void SDLDriver::setVideoMode(bool resetTextures) { -#ifndef HAVE_IRRLICHT - //Is SDL_FreeSurface necessary? SDL wiki says not?? - SDL_FreeSurface(m_main_surface); - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); - - m_main_surface = SDL_SetVideoMode(user_config->m_width, user_config->m_height, 0, m_flags); - - if (!m_main_surface) - { - //ask for lower quality as a fallback - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); - - m_main_surface = SDL_SetVideoMode(user_config->m_width, user_config->m_height, 0, m_flags); - if (m_main_surface) - { - fprintf(stderr, "Using fallback OpenGL settings\n"); - } - else - { - //one last attempt: get rid of the alpha channel - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); - - m_main_surface = SDL_SetVideoMode(user_config->m_width, user_config->m_height, 0, m_flags); - if (m_main_surface) - { - fprintf(stderr, "Using fallback OpenGL settings, without alpha channel\n"); - } - else - { - fprintf(stderr, "SDL_SetVideoMode (%dx%d) failed: %s\n", - user_config->m_width, user_config->m_height, SDL_GetError()); - exit(1); - } - } // !m_main_surface - } // !m_main_surface -#endif #if defined(WIN32) || defined(__APPLE__) if(resetTextures) { @@ -361,10 +308,6 @@ SDLDriver::~SDLDriver() // FIXME LEAK: delete m_action_map if defined SDL_FreeSurface(m_main_surface); -#ifndef HAVE_IRRLICHT - // Irrlicht calls SDL_Quit otherwise - SDL_Quit(); -#endif } // ~SDLDriver //----------------------------------------------------------------------------- diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index aa4681d3d..6aca8d5ec 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -1197,7 +1197,7 @@ void Track::loadTrackModel() // First read the temporary materials.dat file if it exists try { - std::string materials_file = file_manager->getTrackFile("materials.dat",getIdent()); + std::string materials_file = file_manager->getTrackFile("materials.xml",getIdent()); material_manager->pushTempMaterial(materials_file); } catch (std::exception& e)