From: Borrillis <bor...@us...> - 2007-08-31 03:10:02
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv860 Modified Files: mathscript.cpp mathscript.h Log Message: - Moved rpgrules,xml to table - DB Version bump - Added spell_failure Effect during casting Index: mathscript.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/mathscript.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** mathscript.cpp 2 May 2007 19:01:17 -0000 1.48 --- mathscript.cpp 31 Aug 2007 03:09:59 -0000 1.49 *************** *** 38,42 **** #include <csutil/hash.h> #include <csutil/xmltiny.h> ! #include <iutil/vfs.h> #include "util/mathscript.h" --- 38,44 ---- #include <csutil/hash.h> #include <csutil/xmltiny.h> ! ! #include "../server/globals.h" ! #include "psdatabase.h" #include "util/mathscript.h" *************** *** 366,409 **** } ! MathScriptEngine::MathScriptEngine(const char *xmlfile,iVFS *vfs) { ! csRef<iDocumentSystem> xml = csPtr<iDocumentSystem>(new csTinyDocumentSystem); ! ! csRef<iDataBuffer> buff = vfs->ReadFile( xmlfile ); ! if ( !buff || !buff->GetSize() ) ! { ! return; ! } ! ! csRef<iDocument> doc = xml->CreateDocument(); ! const char* error = doc->Parse( buff ); ! if ( error ) ! { ! return; ! } ! csRef<iDocumentNode> root = doc->GetRoot(); ! if (!root) ! return; ! ! csRef<iDocumentNode> topNode = root->GetNode("mathscript"); ! if (!topNode) ! return; ! csRef<iDocumentNodeIterator> iter = topNode->GetNodes(); ! while ( iter->HasNext() ) { ! csRef<iDocumentNode> node = iter->Next(); ! ! if (node->GetType() != CS_NODE_ELEMENT ) ! continue; ! ! // This is a widget so read it's factory to create it. ! if ( strcmp( node->GetValue(), "script" ) == 0 ) { ! MathScript *scr = new MathScript(node); unsigned int key = csHashCompute(scr->name); scripts.Put(key,scr); ! } ! } } --- 368,386 ---- } ! MathScriptEngine::MathScriptEngine() { ! Result result_events(db->Select("SELECT * from math_scripts")); ! if ( result_events.IsValid() ) { ! for ( size_t index = 0; index < result_events.Count(); index++ ) { ! unsigned long x = (unsigned long)index; // remove casting warnings ! ! MathScript *scr = new MathScript(result_events[x]["name"], result_events[x]["math_script"]); unsigned int key = csHashCompute(scr->name); scripts.Put(key,scr); ! } ! } } Index: mathscript.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/mathscript.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** mathscript.h 30 Apr 2007 02:57:27 -0000 1.18 --- mathscript.h 31 Aug 2007 03:09:59 -0000 1.19 *************** *** 197,202 **** }; - struct iVFS; - /** * This holds all the formulas loaded by /data/rpgrules.xml --- 197,200 ---- *************** *** 213,217 **** public: ! MathScriptEngine(const char *xmlfile,iVFS *vfs); ~MathScriptEngine(); --- 211,215 ---- public: ! MathScriptEngine(); ~MathScriptEngine(); |