From: <lpa...@us...> - 2014-03-06 14:34:36
|
Revision: 9314 http://sourceforge.net/p/planeshift/code/9314 Author: lpancallo Date: 2014-03-06 14:34:33 +0000 (Thu, 06 Mar 2014) Log Message: ----------- Removed LOG_DUELS (not used), added LOG_MINIGAMES Cleaned up the old DEBUG of minigames. Modified Paths: -------------- trunk/src/client/gui/pawsgameboard.cpp trunk/src/common/util/log.cpp trunk/src/common/util/log.h Modified: trunk/src/client/gui/pawsgameboard.cpp =================================================================== --- trunk/src/client/gui/pawsgameboard.cpp 2014-03-06 14:33:26 UTC (rev 9313) +++ trunk/src/client/gui/pawsgameboard.cpp 2014-03-06 14:34:33 UTC (rev 9314) @@ -33,8 +33,6 @@ using namespace psMiniGame; -//#define DEBUG_MINIGAMES - //----------------------------------------------------------------------------- pawsGameBoard::pawsGameBoard() @@ -90,9 +88,7 @@ Error1("Failed to parse psMGBoardMessage from server."); return; } -#ifdef DEBUG_MINIGAMES - Debug2(LOG_ANY, 0, "psMGBoardMessage: %s\n", msg.ToString(0).GetData()); -#endif + Debug2(LOG_MINIGAMES, 0, "psMGBoardMessage: %s\n", msg.ToString(0).GetData()); // Verify the message counter if (counterSet && !msg.IsNewerThan(currentCounter)) @@ -127,9 +123,8 @@ Error1("Failed to parse psMGStartStopMessage from server."); return; } -#ifdef DEBUG_MINIGAMES - Debug2(LOG_ANY, 0, "psMGStartStopMessage: %s\n", msg.ToString(0).GetData()); -#endif + Debug2(LOG_MINIGAMES, 0, "psMGStartStopMessage: %s\n", msg.ToString(0).GetData()); + } if (!msg.msgStart && visible) @@ -209,9 +204,7 @@ x = (frame.xmax - frame.xmin - w*msg.msgCols)/2; y = (frame.ymax - frame.ymin - h*msg.msgRows)/2; -#ifdef DEBUG_MINIGAMES - Debug5(LOG_ANY, 0, "Using x = %d, y = %d, w = %d and h = %d", x, y, w, h); -#endif + Debug5(LOG_MINIGAMES, 0, "Using x = %d, y = %d, w = %d and h = %d", x, y, w, h); if (w <= 10 || h <= 10) { @@ -313,6 +306,7 @@ whitePieces.Push(piece); else if (piece >= BLACK_1 && piece <= BLACK_7) blackPieces.Push(piece); + Debug2(LOG_MINIGAMES, 0, "Available Piece: %u", piece); } } else @@ -320,6 +314,7 @@ // By default we will have only one white and one black variant of pieces whitePieces.Push(WHITE_1); blackPieces.Push(BLACK_1); + Debug1(LOG_MINIGAMES, 0, "Available Pieces: Only one black and one white"); } // Show the window @@ -371,6 +366,7 @@ // List of available pieces may change if it depends on the current board status if (msg.msgNumOfPieces > 0 && msg.msgPieces) { + Debug1(LOG_MINIGAMES, 0, "Received update of available Pieces"); whitePieces.Empty(); blackPieces.Empty(); for (size_t i = 0; i < msg.msgNumOfPieces; i++) @@ -385,6 +381,7 @@ whitePieces.Push(piece); else if (piece >= BLACK_1 && piece <= BLACK_7) blackPieces.Push(piece); + Debug2(LOG_MINIGAMES, 0, "Available Piece: %u", piece); } } } Modified: trunk/src/common/util/log.cpp =================================================================== --- trunk/src/common/util/log.cpp 2014-03-06 14:33:26 UTC (rev 9313) +++ trunk/src/common/util/log.cpp 2014-03-06 14:34:33 UTC (rev 9314) @@ -68,7 +68,7 @@ "LOG_PETS", "LOG_USER", "LOG_LOOT", - "LOG_DUELS", + "LOG_MINIGAMES", "LOG_DRDATA", "LOG_ACTIONLOCATION", "LOG_ITEM", @@ -108,7 +108,7 @@ "PlaneShift.Log.Pets", "PlaneShift.Log.User", "PlaneShift.Log.Loot", - "PlaneShift.Log.Duels", + "PlaneShift.Log.Minigames", "PlaneShift.Log.DRData", "PlaneShift.Log.ActionLocation", "PlaneShift.Log.Item", Modified: trunk/src/common/util/log.h =================================================================== --- trunk/src/common/util/log.h 2014-03-06 14:33:26 UTC (rev 9313) +++ trunk/src/common/util/log.h 2014-03-06 14:34:33 UTC (rev 9314) @@ -128,8 +128,8 @@ // Random treasure generation LOG_LOOT, - // Never used!! - LOG_DUELS, + // Minigames, boards + LOG_MINIGAMES, // Dead reckoning positional/navigation data (very verbose) LOG_DRDATA, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2014-03-07 17:35:17
|
Revision: 9320 http://sourceforge.net/p/planeshift/code/9320 Author: ralphcampbell Date: 2014-03-07 17:35:14 +0000 (Fri, 07 Mar 2014) Log Message: ----------- Fix gcc warnings when --enable-debug is used. Modified Paths: -------------- trunk/src/client/gui/pawsactivemagicwindow.cpp trunk/src/client/gui/shortcutwindow.cpp trunk/src/client/pscelclient.cpp trunk/src/server/bulkobjects/activespell.cpp Modified: trunk/src/client/gui/pawsactivemagicwindow.cpp =================================================================== --- trunk/src/client/gui/pawsactivemagicwindow.cpp 2014-03-07 07:08:52 UTC (rev 9319) +++ trunk/src/client/gui/pawsactivemagicwindow.cpp 2014-03-07 17:35:14 UTC (rev 9320) @@ -236,9 +236,6 @@ void pawsActiveMagicWindow::AutoResize() { - int buffSize = 0, - t = 0; - if(!buffList) { return; @@ -293,7 +290,7 @@ newRightEdge =leftEdge+buffList->GetTotalButtonWidth()+16; if( newRightEdge>psengine->GetG2D()->GetWidth() ) { - newRightEdge==psengine->GetG2D()->GetWidth(); + newRightEdge=psengine->GetG2D()->GetWidth(); } } else //this will push it over the right edge of the screen, adjust Modified: trunk/src/client/gui/shortcutwindow.cpp =================================================================== --- trunk/src/client/gui/shortcutwindow.cpp 2014-03-07 07:08:52 UTC (rev 9319) +++ trunk/src/client/gui/shortcutwindow.cpp 2014-03-07 17:35:14 UTC (rev 9320) @@ -55,7 +55,6 @@ //============================================================================= pawsShortcutWindow::pawsShortcutWindow() : - MenuBar(NULL), textBox(NULL), labelBox(NULL), shortcutText(NULL), @@ -65,6 +64,7 @@ iconDisplay(NULL), iconDisplayID(0), editedButton(NULL), + MenuBar(NULL), UpButton(NULL), DownButton(NULL), position(0), Modified: trunk/src/client/pscelclient.cpp =================================================================== --- trunk/src/client/pscelclient.cpp 2014-03-07 07:08:52 UTC (rev 9319) +++ trunk/src/client/pscelclient.cpp 2014-03-07 17:35:14 UTC (rev 9320) @@ -262,7 +262,7 @@ // Extra steps for a controlled actor/the main player: if((!local_player && player_name == msg.name) || - local_player && local_player->GetEID() == msg.entityid) + (local_player && local_player->GetEID() == msg.entityid)) { SetMainActor(actor); Modified: trunk/src/server/bulkobjects/activespell.cpp =================================================================== --- trunk/src/server/bulkobjects/activespell.cpp 2014-03-07 07:08:52 UTC (rev 9319) +++ trunk/src/server/bulkobjects/activespell.cpp 2014-03-07 17:35:14 UTC (rev 9320) @@ -54,10 +54,13 @@ //---------------------------------------------------------------------------- ActiveSpell::ActiveSpell(const csString &name, SPELL_TYPE type, csTicks duration) : name(name), type(type), duration(duration), cancelOnDeath(true), damagesHP(false), target(NULL), registrationTime(0) -{ } -ActiveSpell::ActiveSpell(const csString &name, SPELL_TYPE type, csTicks duration, const csString &image) : name(name), type(type), duration(duration), cancelOnDeath(true), damagesHP(false), target(NULL), registrationTime(0), image(image) -{ } +{ +} +ActiveSpell::ActiveSpell(const csString &name, SPELL_TYPE type, csTicks duration, const csString &image) : name(name), image(image), type(type), duration(duration), cancelOnDeath(true), damagesHP(false), target(NULL), registrationTime(0) +{ +} + void ActiveSpell::Add(iSpellModifier &mod, const char* fmt, ...) { CS_ASSERT(registrationTime == 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2014-03-07 21:05:44
|
Revision: 9323 http://sourceforge.net/p/planeshift/code/9323 Author: ralphcampbell Date: 2014-03-07 21:05:39 +0000 (Fri, 07 Mar 2014) Log Message: ----------- Remove uses of csWeakRef<MathScript>. The scripts are almost never reloaded so it is more efficient to reuse the same MathScript memory rather than test the pointer for NULL each time the pointer is dereferenced. Modified Paths: -------------- trunk/src/client/actionhandler.h trunk/src/client/guihandler.h trunk/src/common/effects/pseffectlight.h trunk/src/common/engine/colldet.h trunk/src/common/engine/linmove.h trunk/src/common/paws/pawsobjectview.cpp trunk/src/common/paws/pawsscript.cpp trunk/src/common/util/mathscript.cpp trunk/src/common/util/mathscript.h trunk/src/common/util/mathscript_unittest.cpp trunk/src/npcclient/npcoperations.cpp trunk/src/npcclient/npcoperations.h trunk/src/npcclient/reaction.cpp trunk/src/npcclient/reaction.h trunk/src/server/actionmanager.cpp trunk/src/server/bankmanager.cpp trunk/src/server/bankmanager.h trunk/src/server/bulkobjects/dictionary.cpp trunk/src/server/bulkobjects/dictionary.h trunk/src/server/bulkobjects/psattackdefault.cpp trunk/src/server/bulkobjects/psattackdefault.h trunk/src/server/bulkobjects/pscharacter.cpp trunk/src/server/bulkobjects/pscharacter.h trunk/src/server/bulkobjects/pscharinventory.cpp trunk/src/server/bulkobjects/psitem.cpp trunk/src/server/bulkobjects/psminigameboard.h trunk/src/server/bulkobjects/psnpcloader.cpp trunk/src/server/bulkobjects/psspell.cpp trunk/src/server/bulkobjects/pstrade.cpp trunk/src/server/bulkobjects/pstrade.h trunk/src/server/cachemanager.cpp trunk/src/server/cachemanager.h trunk/src/server/entitymanager.cpp trunk/src/server/gem.cpp trunk/src/server/lootrandomizer.cpp trunk/src/server/lootrandomizer.h trunk/src/server/minigamemanager.cpp trunk/src/server/npcmanager.cpp trunk/src/server/npcmanager.h trunk/src/server/progressionmanager.cpp trunk/src/server/progressionmanager.h trunk/src/server/psserverchar.cpp trunk/src/server/psserverchar.h trunk/src/server/psserverdr.cpp trunk/src/server/psserverdr.h trunk/src/server/scripting.cpp trunk/src/server/serversongmngr.cpp trunk/src/server/serversongmngr.h trunk/src/server/slotmanager.cpp trunk/src/server/slotmanager.h trunk/src/server/workmanager.cpp trunk/src/server/workmanager.h Modified: trunk/src/client/actionhandler.h =================================================================== --- trunk/src/client/actionhandler.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/client/actionhandler.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -29,7 +29,6 @@ //============================================================================= #include <csutil/parray.h> #include <csutil/ref.h> -#include <csutil/weakref.h> //============================================================================= // Project Includes Modified: trunk/src/client/guihandler.h =================================================================== --- trunk/src/client/guihandler.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/client/guihandler.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -26,7 +26,6 @@ //============================================================================= #include <csutil/parray.h> #include <csutil/ref.h> -#include <csutil/weakref.h> //============================================================================= // Project Includes Modified: trunk/src/common/effects/pseffectlight.h =================================================================== --- trunk/src/common/effects/pseffectlight.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/effects/pseffectlight.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -22,7 +22,6 @@ #include <csgeom/matrix3.h> #include <csutil/cscolor.h> -#include <csutil/weakref.h> #include <csutil/scf_implementation.h> #include <iengine/movable.h> #include <iengine/sector.h> Modified: trunk/src/common/engine/colldet.h =================================================================== --- trunk/src/common/engine/colldet.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/engine/colldet.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -33,7 +33,6 @@ #include <csutil/scf.h> #include <csutil/stringarray.h> #include <csutil/sysfunc.h> -#include <csutil/weakref.h> #include <cstool/collider.h> #include <ivaria/collider.h> Modified: trunk/src/common/engine/linmove.h =================================================================== --- trunk/src/common/engine/linmove.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/engine/linmove.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -31,7 +31,6 @@ #include "iutil/comp.h" #include "iutil/eventh.h" #include "csutil/scf.h" -#include "csutil/weakref.h" #include "csutil/stringarray.h" #include "cstool/collider.h" #include "ivaria/collider.h" Modified: trunk/src/common/paws/pawsobjectview.cpp =================================================================== --- trunk/src/common/paws/pawsobjectview.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/paws/pawsobjectview.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -21,7 +21,6 @@ #include <csutil/documenthelper.h> #include <csutil/scfstringarray.h> -#include <csutil/weakref.h> #include <iutil/object.h> #include <iutil/objreg.h> Modified: trunk/src/common/paws/pawsscript.cpp =================================================================== --- trunk/src/common/paws/pawsscript.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/paws/pawsscript.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -39,7 +39,6 @@ MathScript::Destroy(script); } - void pawsScriptStatement::ChangedResultsVarCallback(void* arg) { pawsScriptResult* res = (pawsScriptResult*)arg; Modified: trunk/src/common/util/mathscript.cpp =================================================================== --- trunk/src/common/util/mathscript.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/util/mathscript.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -442,17 +442,16 @@ while (start < script.Length()) { - csString trimmedScript = script.Slice(start).Trim(); + csString trimmedScript = script.Slice(start).LTrim(); - // skip empty lines and full line comments - if(trimmedScript.StartsWith("\r") || trimmedScript.StartsWith("\n") - || trimmedScript.StartsWith("//")) + // skip line comments + if(trimmedScript.StartsWith("//")) { semicolonAt = script.FindFirst("\r\n", start); if(semicolonAt == SIZET_NOT_FOUND) - semicolonAt = script.Length(); - - start = semicolonAt+1; + start = script.Length(); + else + start = semicolonAt+1; continue; } @@ -479,6 +478,8 @@ if (lineCount < 2 || s->scriptLines.Get(lineCount - 2)->GetOpcode() != MATH_IF) { Error2("Failed to create MathScript >%s<. Found else without prior if.", name); + delete s; + return NULL; } opcode = MATH_ELSE; } @@ -514,11 +515,11 @@ if (0/*exp.FindFirst("=") != SIZET_NOT_FOUND*/) { opcode |= MATH_ASSIGN; - st = MathStatement::Create(exp, s->name); + st = MathStatement::Create(exp, name); } else { - st = MathExpression::Create(exp, s->name); + st = MathExpression::Create(exp, name); } } } @@ -593,14 +594,14 @@ line.Collapse(); if (!line.IsEmpty()) { - MathExpression *st = NULL; + MathExpression *st; if(line.FindFirst("=") != SIZET_NOT_FOUND) { - st = MathStatement::Create(line, s->name); + st = MathStatement::Create(line, name); } else { - st = MathExpression::Create(line, s->name); + st = MathExpression::Create(line, name); } if (!st) @@ -623,7 +624,6 @@ mathScript = NULL; } - MathScript::~MathScript() { while (scriptLines.GetSize()) @@ -632,6 +632,12 @@ } } +void MathScript::CopyAndDestroy(MathScript* other) +{ + other->scriptLines.TransferTo(scriptLines); + delete other; +} + double MathScript::Evaluate(MathEnvironment *env) const { MathVar *exitsignal = env->Lookup("exit"); @@ -741,67 +747,71 @@ UnloadScripts(); } -bool MathScriptEngine::LoadScripts(iDataConnection* db) +bool MathScriptEngine::LoadScripts(iDataConnection* db, bool reload) { Result result(db->Select("SELECT * from math_scripts")); if (!result.IsValid()) return false; + size_t old_count = scripts.GetSize(); + bool ok = true; for (unsigned long i = 0; i < result.Count(); i++ ) { - csRef<MathScript> script; - MathScript *scr = MathScript::Create(result[i]["name"], result[i][mathScriptTable]); + const char* name = result[i]["name"]; + MathScript *scr = MathScript::Create(name, result[i][mathScriptTable]); if (!scr) { - Error2("Failed to load MathScript >%s<.", result[i]["name"]); + Error2("Failed to load MathScript >%s<.", name); + ok = false; continue; } - script.AttachNew(scr); - scripts.Put(scr->Name(), script); + + if (reload) + { + MathScript* old = scripts.Get(name, NULL); + if (old) + { + old->CopyAndDestroy(scr); + old_count--; + } + else + { + scripts.Put(name, scr); + } + } + else + { + scripts.Put(name, scr); + } } - return true; + if (reload && old_count != 0) + { + Error2("WARNING: %zu MathScripts were not reloaded.", old_count); + } + return ok; } void MathScriptEngine::UnloadScripts() { - //refcounting should handle this. - /*csHash<csRef<MathScript>, csString>::GlobalIterator it(scripts.GetIterator()); + csHash<MathScript*, csString>::GlobalIterator it(scripts.GetIterator()); while (it.HasNext()) { delete it.Next(); - }*/ + } scripts.DeleteAll(); MathScriptEngine::customCompoundFunctions.Empty(); MathScriptEngine::stringLiterals.Empty(); } - - -csWeakRef<MathScript> MathScriptEngine::FindScript(const csString & name) +MathScript* MathScriptEngine::FindScript(const csString & name) { return scripts.Get(name, NULL); } -bool MathScriptEngine::CheckAndUpdateScript(csWeakRef<MathScript> &script, const csString &name) -{ - //check if we need to reload the script - if(!script.IsValid()) - { - script = FindScript(name); - if(!script.IsValid()) //check if loading succeded else act accordly - { - CPrintf(CON_ERROR,"Couldn't load %s script!", name.GetData()); - return false; - } - } - return true; -} - void MathScriptEngine::ReloadScripts(iDataConnection* db) { - UnloadScripts(); - LoadScripts(db); + LoadScripts(db, true); } csRandomGen MathScriptEngine::rng; Modified: trunk/src/common/util/mathscript.h =================================================================== --- trunk/src/common/util/mathscript.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/util/mathscript.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -51,7 +51,7 @@ class MathScriptEngine { protected: - csHash<csRef<MathScript>, csString> scripts; + csHash<MathScript*, csString> scripts; static csRandomGen rng; static csStringSet stringLiterals; @@ -83,31 +83,18 @@ ~MathScriptEngine(); /// retrieve a MathScript given it's name. - csWeakRef<MathScript> FindScript(const csString & name); + MathScript* FindScript(const csString& name); /** - * Checks if the reference to the script is still valid, if it's not - * updates it. This is an helper function to simplify use of the scripts. - * - * @param script Reference to a script, which will then be used locally - * by the caller. - * @param name The name of the script to check for. - * @return TRUE if the loading succeded or wasn't needed, false if the script - * wasn't found at all - */ - bool CheckAndUpdateScript(csWeakRef<MathScript> &script, const csString &name); - - /** * Triggers a cleanup and reload of all the scripts. */ void ReloadScripts(iDataConnection* db); - /** * Loads all the scripts from the database. * @return TRUE if it was possible to retrieve successfully the data. */ - bool LoadScripts(iDataConnection* db); + bool LoadScripts(iDataConnection* db, bool reload = false); /** * Cleans up all the script and data loaded. @@ -452,7 +439,7 @@ * it parses, it makes a hashmap of all the variables * for quick access. */ -class MathScript : private MathExpression, public csRefCount, public CS::Utility::WeakReferenced +class MathScript : private MathExpression { protected: MathScript(const char *name) : name(name) { } // may only be constructed using MathScript::Create @@ -470,6 +457,8 @@ return name; } + void CopyAndDestroy(MathScript* other); + double Evaluate(MathEnvironment *env) const; }; Modified: trunk/src/common/util/mathscript_unittest.cpp =================================================================== --- trunk/src/common/util/mathscript_unittest.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/common/util/mathscript_unittest.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -69,6 +69,7 @@ EXPECT_EQ(100.0, C->GetValue()); EXPECT_EQ(373.15, K->GetValue()); EXPECT_STREQ("373.15", K->ToString()); + MathScript::Destroy(script); } class Foo : public iScriptableVar @@ -197,6 +198,7 @@ script->Evaluate(&env); MathVar *rank = env.Lookup("Rank"); EXPECT_EQ(77, rank->GetValue()); + MathScript::Destroy(script); }; TEST(MathScriptTest, StringAssignment) @@ -209,6 +211,7 @@ script->Evaluate(&env); MathVar *rank = env.Lookup("Rank"); EXPECT_EQ(33, rank->GetValue()); + MathScript::Destroy(script); }; TEST(MathScriptTest, StringAssignment2) @@ -222,6 +225,7 @@ MathVar *rank = env.Lookup("Skill"); ASSERT_NE(rank, NULL); EXPECT_STREQ("Sword", rank->ToString()); + MathScript::Destroy(script); }; @@ -356,7 +360,7 @@ { EXPECT_TRUE(abovehalflimit) << scriptstr << "never exceeds half of limit"; } - delete script; + MathScript::Destroy(script); } TEST(MathScriptTest, RandomGenTest) { Modified: trunk/src/npcclient/npcoperations.cpp =================================================================== --- trunk/src/npcclient/npcoperations.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/npcclient/npcoperations.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -1140,6 +1140,7 @@ targetEID(EID(0)), offsetAngle(0.0), adaptivVelScale(1.0), + calcAdaptivVelocity(0), // Operation parameters // Initialized in the load function type(NEAREST_PLAYER), @@ -1157,6 +1158,7 @@ // Instance variables targetEID(other->targetEID), adaptivVelScale(1.0), + calcAdaptivVelocity(other->calcAdaptivVelocity), // Operation parameters type(other->type), searchRange(other->searchRange), @@ -1253,6 +1255,12 @@ if(node->GetAttributeValue("adaptiv_vel_script")) { adaptivVelocityScript = node->GetAttributeValue("adaptiv_vel_script"); + calcAdaptivVelocity = npcclient->GetMathScriptEngine()->FindScript(adaptivVelocityScript); + if(!calcAdaptivVelocity) + { + Error2("Failed to load math script for AdaptivVelocity '%s'", adaptivVelocityScript.GetDataSafe()); + return false; + } } return true; @@ -1549,15 +1557,6 @@ float ChaseOperation::AdaptivVelocity(NPC* npc, float distance) { - if(!calcAdaptivVelocity.IsValid()) - { - if(!npcclient->GetMathScriptEngine()->CheckAndUpdateScript(calcAdaptivVelocity, adaptivVelocityScript)) - { - Error2("Failed to load math script for AdaptivVelocity '%s'",adaptivVelocityScript.GetDataSafe()); - return 0.0; - } - } - MathEnvironment env; env.Define("NPCClient", npcclient); @@ -4051,9 +4050,10 @@ bool PerceptOperation::CheckCondition(NPC* npc) { - if(!calcCondition.IsValid()) + if(!calcCondition) { - if(!npcclient->GetMathScriptEngine()->CheckAndUpdateScript(calcCondition, condition)) + calcCondition = npcclient->GetMathScriptEngine()->FindScript(condition); + if(!calcCondition) { Error2("Failed to load math script for PerceptionOperation condition '%s'",condition.GetDataSafe()); return false; @@ -4072,7 +4072,6 @@ env.Define("Target", target); } - //this is going to crash if the script cannot be found. calcCondition->Evaluate(&env); MathVar* result = env.Lookup("Result"); Modified: trunk/src/npcclient/npcoperations.h =================================================================== --- trunk/src/npcclient/npcoperations.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/npcclient/npcoperations.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -478,7 +478,7 @@ float offsetAngle; ///< The actual offset angle in radians csVector3 offsetDelta; ///< The actual delta relative to target float adaptivVelScale; ///< Scale of velocity for adaptive vel. - csWeakRef<MathScript> calcAdaptivVelocity; ///< This is the particular calculation for adaptiv velocity. + MathScript* calcAdaptivVelocity; ///< This is the particular calculation for adaptiv velocity. //@} /** @name Operation Parameters @@ -525,7 +525,7 @@ /** Destructor for this operation */ - virtual ~ChaseOperation() {}; + virtual ~ChaseOperation() {} /** Calculate any offset from target to stop chase. * @@ -1249,11 +1249,17 @@ csString failedPerception; ///< A perception to fire if the condition fails csString delayed; ///< If set this perception should be delayed. - csWeakRef<MathScript> calcCondition; ///< This is the particular calculation for condition. + MathScript* calcCondition; ///< This is the particular calculation for condition. public: - PerceptOperation(): ScriptOperation("Percept"), target(SELF), maxRange(0.0) {}; - virtual ~PerceptOperation() {}; + PerceptOperation() : + ScriptOperation("Percept"), + target(SELF), + maxRange(0.0), + calcCondition(0) + { + } + virtual ~PerceptOperation() {} virtual OperationResult Run(NPC* npc,bool interrupted); virtual bool Load(iDocumentNode* node); virtual ScriptOperation* MakeCopy(); Modified: trunk/src/npcclient/reaction.cpp =================================================================== --- trunk/src/npcclient/reaction.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/npcclient/reaction.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -22,7 +22,6 @@ //============================================================================= // Crystal Space Includes //============================================================================= -#include <csutil/weakref.h> #include <csutil/csstring.h> #include <csutil/array.h> #include <iutil/document.h> @@ -126,7 +125,8 @@ condition = node->GetAttributeValue("condition"); if(!condition.IsEmpty()) { - if(!npcclient->GetMathScriptEngine()->CheckAndUpdateScript(calcCondition, condition)) + calcCondition = npcclient->GetMathScriptEngine()->FindScript(condition); + if(!calcCondition) { Error2("Failed to load math script for Reaction condition '%s'",condition.GetDataSafe()); return false; @@ -278,7 +278,6 @@ env.Define("NPC", who); env.Define("Result", 0.0); - //this is going to crash if the script cannot be found. calcCondition->Evaluate(&env); MathVar* result = env.Lookup("Result"); Modified: trunk/src/npcclient/reaction.h =================================================================== --- trunk/src/npcclient/reaction.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/npcclient/reaction.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -23,7 +23,6 @@ //============================================================================= // Crystal Space Includes //============================================================================= -#include <csutil/weakref.h> #include <csutil/csstring.h> #include <csutil/array.h> #include <iutil/document.h> @@ -60,7 +59,7 @@ int factionDiff; csString oper; csString condition; - csWeakRef<MathScript> calcCondition; ///< This is the particular calculation for condition. + MathScript* calcCondition; ///< This is the particular calculation for condition. bool activeOnly; bool inactiveOnly; bool reactWhenDead; Modified: trunk/src/server/actionmanager.cpp =================================================================== --- trunk/src/server/actionmanager.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/actionmanager.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -757,11 +757,12 @@ { csString parameters = actionlocation->GetAction()->GetScriptParameters(); // passes the parameters to the script to run - csWeakRef<MathScript> bindings = MathScript::Create("RunScript bindings", parameters); + MathScript* bindings = MathScript::Create("RunScript bindings", parameters); MathEnvironment env; env.Define("Target", client->GetActor()); // needed if called by an action location bindings->Evaluate(&env); + MathScript::Destroy(bindings); progScript->Run(&env); return true; } Modified: trunk/src/server/bankmanager.cpp =================================================================== --- trunk/src/server/bankmanager.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bankmanager.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -82,9 +82,10 @@ } //load the mathscripts - psserver->GetMathScriptEngine()->CheckAndUpdateScript(accountGuildLvlScript, "Calc Guild Account Level"); - psserver->GetMathScriptEngine()->CheckAndUpdateScript(accountCharLvlScript, "Calc Char Account Level"); - psserver->GetMathScriptEngine()->CheckAndUpdateScript(CalcBankFeeScript, "Calc Bank Fee"); + MathScriptEngine* eng = psserver->GetMathScriptEngine(); + accountGuildLvlScript = eng->FindScript("Calc Guild Account Level"); + accountCharLvlScript = eng->FindScript("Calc Char Account Level"); + CalcBankFeeScript = eng->FindScript("Calc Bank Fee"); ProcessTax(); } @@ -799,7 +800,7 @@ return 0; } - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(accountGuildLvlScript, "Calc Guild Account Level")) + if(!accountGuildLvlScript) { return 0; } @@ -808,7 +809,7 @@ } else { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(accountCharLvlScript, "Calc Char Account Level")) + if(!accountCharLvlScript) { return 0; } @@ -824,14 +825,13 @@ float BankManager::CalculateFee(psCharacter* pschar, bool guild) { - MathEnvironment env; - env.Define("AccountLevel", CalculateAccountLevel(pschar, guild)); - - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(CalcBankFeeScript, "Calc Bank Fee")) + if(!CalcBankFeeScript) { return 0; } + MathEnvironment env; + env.Define("AccountLevel", CalculateAccountLevel(pschar, guild)); CalcBankFeeScript->Evaluate(&env); MathVar* bankFee = env.Lookup("BankFee"); return bankFee->GetValue(); Modified: trunk/src/server/bankmanager.h =================================================================== --- trunk/src/server/bankmanager.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bankmanager.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -78,9 +78,9 @@ csArray<MoneyEvent> monEvts; - csWeakRef<MathScript> accountCharLvlScript; - csWeakRef<MathScript> accountGuildLvlScript; - csWeakRef<MathScript> CalcBankFeeScript; + MathScript* accountCharLvlScript; + MathScript* accountGuildLvlScript; + MathScript* CalcBankFeeScript; }; Modified: trunk/src/server/bulkobjects/dictionary.cpp =================================================================== --- trunk/src/server/bulkobjects/dictionary.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/dictionary.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -2303,11 +2303,7 @@ RunScriptResponseOp::~RunScriptResponseOp() { - if(bindings) - { - delete bindings; - bindings = NULL; - } + MathScript::Destroy(bindings); } bool RunScriptResponseOp::Load(iDocumentNode* node) Modified: trunk/src/server/bulkobjects/dictionary.h =================================================================== --- trunk/src/server/bulkobjects/dictionary.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/dictionary.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -876,7 +876,7 @@ protected: csString scriptname; csString bindingsText; - csWeakRef<MathScript> bindings; + MathScript* bindings; public: RunScriptResponseOp() Modified: trunk/src/server/bulkobjects/psattackdefault.cpp =================================================================== --- trunk/src/server/bulkobjects/psattackdefault.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/psattackdefault.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -57,22 +57,10 @@ psAttackDefault::psAttackDefault() { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(calc_damage, "Calculate Damage"); - psserver->GetMathScriptEngine()->CheckAndUpdateScript(calc_decay, "Calculate Decay"); - psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminacombat, "StaminaCombat"); - if(!calc_damage) - { - Error1("Calculate Damage Script could not be found. Check the math_scripts DB table."); - } - else if(!calc_decay) - { - Error1("Calculate Decay Script could not be found. Check the math_scripts DB table."); - } } psAttackDefault::~psAttackDefault() { - } bool psAttackDefault::IsDualWield(psCharacter* attacker) @@ -94,11 +82,13 @@ else return false; } + bool psAttackDefault::Load(iResultRow &row) { //no need to load anything for this particular attack return true; } + bool psAttackDefault::CanAttack(Client* client) { //default attack can always attack @@ -111,6 +101,7 @@ QueueAttack(attacker,slot,target,attacker->GetClientID(),target->GetClientID()); return true; } + void psAttackDefault::QueueAttack(gemObject* attacker,INVENTORY_SLOT_NUMBER weaponslot,gemObject* target,int attackerCID, int targetCID) { psCharacter* Character=attacker->GetCharacterData(); @@ -123,8 +114,8 @@ event = new psCombatAttackGameEvent(delay,this,attacker,target,weaponslot,attackerCID,targetCID); event->GetAttackerData()->TagEquipmentObject(weaponslot,event->id); psserver->GetEventManager()->Push(event); +} -} void psAttackDefault::Affect(psCombatAttackGameEvent* event) { @@ -192,14 +183,7 @@ env.Define("Actor", event->GetAttacker()); env.Define("Weapon", weapon); - //as this is called frequently we precheck before doing a function - //call if we need to reload the script - if(!staminacombat.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminacombat, "StaminaCombat"); - } - //this is going to crash if the script was not found in the db. - staminacombat->Evaluate(&env); + (void) psserver->GetCacheManager()->GetStaminaCombat()->Evaluate(&env); MathVar* PhyDrain = env.Lookup("PhyDrain"); MathVar* MntDrain = env.Lookup("MntDrain"); @@ -240,7 +224,6 @@ } } - if(gemAttacker->IsSpellCasting()) { psserver->SendSystemInfo(event->AttackerCID, "You can't attack while casting spells."); @@ -308,7 +291,6 @@ event->AttackResult=attack_result; AffectTarget(event,attack_result); } - } int psAttackDefault::CalculateAttack(psCombatAttackGameEvent* event, psItem* subWeapon) @@ -350,16 +332,8 @@ env.Define("DiffY", diff.y ? diff.y : 0.00001F); // force minimal value env.Define("DiffZ", diff.z ? diff.z : 0.00001F); // force minimal value - //as this is called frequently we precheck before doing a function - //call if we need to reload the script - if(!calc_damage.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(calc_damage, "Calculate Damage"); - } + (void) psserver->GetCacheManager()->GetCalcDamage()->Evaluate(&env); - //this is going to crash if the script cannot be found. - calc_damage->Evaluate(&env); - if(DoLogDebug2(LOG_COMBAT, event->GetAttackerData()->GetPID().Unbox())) { CPrintf(CON_DEBUG, "Variables for Calculate Damage:\n"); @@ -388,6 +362,7 @@ return ATTACK_DAMAGE; } + void psAttackDefault::AffectTarget(psCombatAttackGameEvent* event, int attack_result) { psCharacter* attacker_data = event->GetAttackerData(); @@ -419,16 +394,8 @@ env.Define("Damage", event->FinalDamage); // actual damage dealt env.Define("Blocked", (attack_result == ATTACK_BLOCKED)); // identifies whether this attack was blocked - //as this is called frequently we precheck before doing a function - //call if we need to reload the script - if(!calc_decay.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(calc_decay, "Calculate Decay"); - } + (void) psserver->GetCacheManager()->GetCalcDecay()->Evaluate(&env); - //this is going to crash if the script cannot be found. - calc_decay->Evaluate(&env); - weaponDecay = env.Lookup("WeaponDecay"); blockDecay = env.Lookup("BlockingDecay"); armorDecay = env.Lookup("ArmorDecay"); Modified: trunk/src/server/bulkobjects/psattackdefault.h =================================================================== --- trunk/src/server/bulkobjects/psattackdefault.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/psattackdefault.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -79,11 +79,7 @@ * Queues up the next attack, specific to the default attack at the moment */ void QueueAttack(gemObject* attacker,INVENTORY_SLOT_NUMBER weaponslot,gemObject* target,int attackerCID, int targetCID); - csWeakRef<MathScript> calc_damage; ///< This is the particular calculation for damage. - csWeakRef<MathScript> calc_decay; ///< This is the particular calculation for decay. - csWeakRef<MathScript> staminacombat;///< if the player is too tired, stop fighting. We stop if we don't have enough stamina to make an attack with the current stance. - bool IsQueuedInClient() { return false; Modified: trunk/src/server/bulkobjects/pscharacter.cpp =================================================================== --- trunk/src/server/bulkobjects/pscharacter.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/pscharacter.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -81,19 +81,6 @@ const char* psCharacter::characterTypeName[] = { "player", "npc", "pet", "mount", "mountpet" }; -csWeakRef<MathScript> psCharacter::maxRealmScript = NULL; -csWeakRef<MathScript> psCharacter::staminaCalc = NULL; -csWeakRef<MathScript> psCharacter::expSkillCalc = NULL; -csWeakRef<MathScript> psCharacter::staminaRatioWalk = NULL; -csWeakRef<MathScript> psCharacter::staminaRatioStill = NULL; -csWeakRef<MathScript> psCharacter::staminaRatioSit = NULL; -csWeakRef<MathScript> psCharacter::staminaRatioWork = NULL; -csWeakRef<MathScript> psCharacter::dodgeValueCalc = NULL; -csWeakRef<MathScript> psCharacter::armorSkillsPractice = NULL; -csWeakRef<MathScript> psCharacter::charLevelGet = NULL; -csWeakRef<MathScript> psCharacter::skillValuesGet = NULL; -csWeakRef<MathScript> psCharacter::baseSkillValuesGet = NULL; - //----------------------------------------------------------------------------- @@ -185,116 +172,6 @@ isStatue = false; attackQueue.AttachNew(new psAttackQueue()); - // Load the math scripts - if(!staminaCalc.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaCalc, "StaminaBase"); - if(!staminaCalc.IsValid()) - { - Error1("Can't find math script StaminaBase! Character loading failed."); - } - } - - if(!staminaRatioWalk.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioWalk, "StaminaRatioWalk"); - if(!staminaRatioWalk.IsValid()) - { - Error1("Can't find math script StaminaRatioWalk! Character loading failed."); - } - } - - if(!staminaRatioStill.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioStill, "StaminaRatioStill"); - if(!staminaRatioStill.IsValid()) - { - Error1("Can't find math script StaminaRatioStill! Character loading failed."); - } - } - - if(!staminaRatioSit.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioSit, "StaminaRatioSit"); - if(!staminaRatioSit.IsValid()) - { - Error1("Can't find math script StaminaRatioSit! Character loading failed."); - } - } - - if(!staminaRatioWork.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioWork, "StaminaRatioWork"); - if(!staminaRatioWork.IsValid()) - { - Error1("Can't find math script StaminaRatioWork! Character loading failed."); - } - } - - if(!expSkillCalc.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(expSkillCalc, "Calculate Skill Experience"); - if(!expSkillCalc.IsValid()) - { - Error1("Can't find 'Calculate Skill Experience' math script. Character loading failed."); - } - } - - if(!maxRealmScript.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(maxRealmScript, "MaxRealm"); - if(!maxRealmScript.IsValid()) - { - Error1("Can't find math script MaxRealm! Character loading failed."); - } - } - - if(!dodgeValueCalc.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(dodgeValueCalc, "CalculateDodgeValue"); - if(!dodgeValueCalc.IsValid()) - { - Error1("Can't find math script CalculateDodgeValue! Character loading failed."); - } - } - - - if(!armorSkillsPractice.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(armorSkillsPractice, "PracticeArmorSkills"); - if(!armorSkillsPractice.IsValid()) - { - Error1("Can't find math script PracticeArmorSkills! Character loading failed."); - } - } - - if(!charLevelGet.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(charLevelGet, "GetCharLevel"); - if(!charLevelGet.IsValid()) - { - Error1("Can't find math script GetCharLevel! Character loading failed."); - } - } - - - if(!skillValuesGet.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(skillValuesGet, "GetSkillValues"); - if(!skillValuesGet.IsValid()) - { - Error1("Can't find math script GetSkillValues! Character loading failed."); - } - } - - if(!baseSkillValuesGet.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(baseSkillValuesGet, "GetSkillBaseValues"); - if(!baseSkillValuesGet.IsValid()) - { - Error1("Can't find math script GetSkillBaseValues! Character loading failed."); - } - } } psCharacter::~psCharacter() @@ -1120,9 +997,6 @@ if(!raceInfo) return; - csWeakRef<MathScript> setBaseSkillsScript; - psserver->GetMathScriptEngine()->CheckAndUpdateScript(setBaseSkillsScript, "SetBaseSkills"); - MathEnvironment env; env.Define("Actor", character); env.Define("STR", raceInfo->GetBaseAttribute(PSITEMSTATS_STAT_STRENGTH)); @@ -1132,7 +1006,7 @@ env.Define("WILL", raceInfo->GetBaseAttribute(PSITEMSTATS_STAT_WILL)); env.Define("CHA", raceInfo->GetBaseAttribute(PSITEMSTATS_STAT_CHARISMA)); - setBaseSkillsScript->Evaluate(&env); + (void) psserver->GetCacheManager()->GetSetBaseSkillsScript()->Evaluate(&env); //as we are changing or obtaining for the first time a race set the inventory correctly for this. character->Inventory().SetBasicArmor(raceInfo); @@ -1402,14 +1276,6 @@ { if(practicePoints > 0) { - if(!expSkillCalc.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(expSkillCalc, "Calculate Skill Experience")) - { - return 0; - } - } - MathEnvironment env; env.Define("ZCost", skills.Get(skill).zCost); env.Define("YCost", skills.Get(skill).yCost); @@ -1418,7 +1284,7 @@ env.Define("Character", this); env.Define("PracticePoints", practicePoints); env.Define("Modifier", modifier); - expSkillCalc->Evaluate(&env); + (void) psserver->GetCacheManager()->GetExpSkillCalc()->Evaluate(&env); unsigned int experiencePoints = env.Lookup("Exp")->GetRoundValue(); if(GetActor()->GetClient()->GetSecurityLevel() >= GM_DEVELOPER) @@ -1497,22 +1363,15 @@ MathEnvironment env; env.Define("WaySkill", waySkillRank); - if(!maxRealmScript.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(maxRealmScript, "MaxRealm")) - { - return 0; - } - } + (void) psserver->GetCacheManager()->GetMaxRealmScript()->Evaluate(&env); - maxRealmScript->Evaluate(&env); - MathVar* maxRealm = env.Lookup("MaxRealm"); if(!maxRealm) { Error1("Failed to evaluate MathScript >MaxRealm<."); return 0; } + return maxRealm->GetRoundValue(); } @@ -1908,16 +1767,6 @@ void psCharacter::CombatDrain(int slot) { - static csWeakRef<MathScript> script = NULL; - - if(!script.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(script, "StaminaCombat")) - { - return; - } - } - psItem* weapon = inventory.GetEffectiveWeaponInSlot((INVENTORY_SLOT_NUMBER) slot); if(!weapon)//shouldn't happen return; @@ -1926,7 +1775,7 @@ env.Define("Actor", GetActor()); env.Define("Weapon", weapon); - script->Evaluate(&env); + (void) psserver->GetCacheManager()->GetStaminaCombat()->Evaluate(&env); MathVar* phyDrain = env.Lookup("PhyDrain"); MathVar* mntDrain = env.Lookup("MntDrain"); @@ -2054,24 +1903,13 @@ env.Define("BaseRegenPhysical", GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_PHYSICAL_WALK]); env.Define("BaseRegenMental", GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_MENTAL_WALK]); - //check if the mathscript is still valid else try to reload it - if(!staminaRatioWalk.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioWalk, "StaminaRatioWalk")) - { - return; - } - } - staminaRatioWalk->Evaluate(&env); + (void) psserver->GetCacheManager()->GetStaminaRatioWalk()->Evaluate(&env); MathVar* ratePhy = env.Lookup("PStaminaRate"); MathVar* rateMen = env.Lookup("MStaminaRate"); if(physical && ratePhy) GetPStaminaRate().SetBase(ratePhy->GetValue()); if(mental && rateMen) GetMStaminaRate().SetBase(rateMen->GetValue()); - - //if(physical) GetPStaminaRate().SetBase(GetMaxPStamina().Current()/100 * GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_PHYSICAL_WALK]); - //if(mental) GetMStaminaRate().SetBase(GetMaxMStamina().Current()/100 * GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_MENTAL_WALK]); } void psCharacter::SetStaminaRegenerationSitting() @@ -2081,25 +1919,14 @@ env.Define("BaseRegenPhysical", GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_PHYSICAL_STILL]); env.Define("BaseRegenMental", GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_MENTAL_STILL]); - //check if the mathscript is still valid else try to reload it - if(!staminaRatioSit.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioSit, "StaminaRatioSit")) - { - return; - } - } - staminaRatioSit->Evaluate(&env); + (void) psserver->GetCacheManager()->GetStaminaRatioSit()->Evaluate(&env); MathVar* ratePhy = env.Lookup("PStaminaRate"); MathVar* rateMen = env.Lookup("MStaminaRate"); if(ratePhy) GetPStaminaRate().SetBase(ratePhy->GetValue()); if(rateMen) GetMStaminaRate().SetBase(rateMen->GetValue()); - - //GetPStaminaRate().SetBase(GetMaxPStamina().Current() * 0.015 * GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_PHYSICAL_STILL]); - //GetMStaminaRate().SetBase(GetMaxMStamina().Current() * 0.015 * GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_MENTAL_STILL]); } void psCharacter::SetStaminaRegenerationStill(bool physical,bool mental) @@ -2110,25 +1937,13 @@ env.Define("BaseRegenPhysical", GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_PHYSICAL_STILL]); env.Define("BaseRegenMental", GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_MENTAL_STILL]); - //check if the mathscript is still valid else try to reload it - if(!staminaRatioStill.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioStill, "StaminaRatioStill")) - { - return; - } - } + (void) psserver->GetCacheManager()->GetStaminaRatioStill()->Evaluate(&env); - staminaRatioStill->Evaluate(&env); - MathVar* ratePhy = env.Lookup("PStaminaRate"); MathVar* rateMen = env.Lookup("MStaminaRate"); if(physical && ratePhy) GetPStaminaRate().SetBase(ratePhy->GetValue()); if(mental && rateMen) GetMStaminaRate().SetBase(rateMen->GetValue()); - - //if(physical) GetPStaminaRate().SetBase(GetMaxPStamina().Current()/100 * GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_PHYSICAL_STILL]); - //if(mental) GetMStaminaRate().SetBase(GetMaxMStamina().Current()/100 * GetRaceInfo()->baseRegen[PSRACEINFO_STAMINA_MENTAL_STILL]); } void psCharacter::SetStaminaRegenerationWork(int skill) @@ -2150,23 +1965,13 @@ env.Define("SkillMentalFactor", factor); - //check if the mathscript is still valid else try to reload it - if(!staminaRatioWork.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaRatioWork, "StaminaRatioWork")) - { - return; - } - } + (void) psserver->GetCacheManager()->GetStaminaRatioWork()->Evaluate(&env); - staminaRatioWork->Evaluate(&env); - MathVar* ratePhy = env.Lookup("PStaminaRate"); MathVar* rateMen = env.Lookup("MStaminaRate"); if(ratePhy) GetPStaminaRate().SetBase(ratePhy->GetValue()); if(rateMen) GetMStaminaRate().SetBase(rateMen->GetValue()); - } void psCharacter::CalculateMaxStamina() @@ -2175,17 +1980,8 @@ // Set the actor to retreive the skill values from env.Define("Actor", this); - // Calculate after checking if the script is valid and restoring validity if possible - if(!staminaCalc.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(staminaCalc, "StaminaBase")) - { - return; - } - } + (void) psserver->GetCacheManager()->GetStaminaCalc()->Evaluate(&env); - staminaCalc->Evaluate(&env); - MathVar* basePhy = env.Lookup("BasePhy"); MathVar* baseMen = env.Lookup("BaseMen"); if(!basePhy || !baseMen) @@ -2351,43 +2147,13 @@ env.Define("MediumPoints", med_p); env.Define("LightPoints", light_p); - //check if mathscript is valid else try to reload it - if(!dodgeValueCalc.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(dodgeValueCalc, "CalculateDodgeValue")) - { - return 0; - } - } + (void) psserver->GetCacheManager()->GetDodgeValueCalc()->Evaluate(&env); - dodgeValueCalc->Evaluate(&env); - return env.Lookup("Result")->GetValue(); - - /* - * - * Should be implemented in the script if needed. - * - // MADM= Martial Arts Defense Mod=martial arts skill-(weight carried+ AGI malus of the armor +DEX malus of the armor) min 0 - // TODO: fix this to use armor agi malus - madm=GetSkillRank(PSSKILL_MARTIALARTS).Current()-inventory.weight; - if (madm<0.0f) - madm=0.0f; - - // Active Dodge Value =ADV = (ASDM + agiDmod + MADM)*ADVP)^0.4 - // Out of Melee Defense Value=OMDV = (agiDmod+(ASDM\10)*PDVP)^0.4 - - // TODO: Use passive dv here when the conditions are finalized that it should be used (archery, casting, more?) - - dv=asdm + AgiMod + madm; - dv=pow(dv,(float)0.6); - - return dv; - */ } /** - * PracticesArmorSkills is never used. + * PracticeArmorSkills is never used. */ void psCharacter::PracticeArmorSkills(unsigned int practice, INVENTORY_SLOT_NUMBER attackLocation) { @@ -2418,17 +2184,7 @@ env.Define("MediumPoints", med_p); env.Define("LightPoints", light_p); - //check if mathscript is valid else try to reload it - if(!armorSkillsPractice.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(armorSkillsPractice, "PracticeArmorSkills")) - { - return; - } - } - - armorSkillsPractice->Evaluate(&env); - + (void) psserver->GetCacheManager()->GetArmorSkillsPractice()->Evaluate(&env); } /** @@ -3073,33 +2829,15 @@ void psCharacter::GetSkillValues(MathEnvironment* env) { env->Define("Actor", this); - //check if the mathscript is still valid else try to reload it - if(!skillValuesGet.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(skillValuesGet, "GetSkillValues")) - { - return; - } - } - skillValuesGet->Evaluate(env); + (void) psserver->GetCacheManager()->GetSkillValuesGet()->Evaluate(env); } void psCharacter::GetSkillBaseValues(MathEnvironment* env) { env->Define("Actor", this); - //check if the mathscript is still valid else try to reload it - if(!baseSkillValuesGet.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(baseSkillValuesGet, "GetSkillBaseValues")) - { - return; - } - } - baseSkillValuesGet->Evaluate(env); + (void) psserver->GetCacheManager()->GetBaseSkillValuesGet()->Evaluate(env); } - - void psCharacter::Train(PSSKILL skill, int yIncrease) { skills.Train(skill, yIncrease); // Normal training @@ -3138,7 +2876,7 @@ return; // Calc the new Y/Z cost - csWeakRef<MathScript> script = psserver->GetMathScriptEngine()->FindScript(info->costScript); + MathScript* script = psserver->GetMathScriptEngine()->FindScript(info->costScript); if(!script) { Error4("Couldn't find script %s to calculate skill cost of %d (%s)!", @@ -3154,7 +2892,7 @@ env.Define("MentalFactor", info->mental_factor); env.Define("Actor", user); - script->Evaluate(&env); + (void) script->Evaluate(&env); MathVar* yCostVar = env.Lookup("YCost"); MathVar* zCostVar = env.Lookup("ZCost"); @@ -3258,19 +2996,10 @@ { MathEnvironment env; env.Define("Actor", this); - env.Define("Physical", (physical ? 1 : 0)); - //check if the mathscript is still valid else try to reload it - if(!charLevelGet.IsValid()) - { - if(!psserver->GetMathScriptEngine()->CheckAndUpdateScript(charLevelGet, "GetCharLevel")) - { - return 0; - } - } + (void) psserver->GetCacheManager()->GetCharLevelGet()->Evaluate(&env); - charLevelGet->Evaluate(&env); return env.Lookup("Result")->GetRoundValue(); } @@ -3280,22 +3009,13 @@ MathEnvironment env; // safe enough to reuse...and faster... env.Define("Actor", this); - // Calculate current Max Mana level: - static csWeakRef<MathScript> maxManaScript; - if(!maxManaScript.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(maxManaScript, "CalculateMaxMana"); - CS_ASSERT(maxManaScript.IsValid()); - } - - if(overrideMaxMana) { GetMaxMana().SetBase(overrideMaxMana); } - else if(maxManaScript.IsValid()) + else { - maxManaScript->Evaluate(&env); + (void) psserver->GetCacheManager()->GetMaxManaScript()->Evaluate(&env); MathVar* maxMana = env.Lookup("MaxMana"); if(maxMana) { @@ -3307,22 +3027,13 @@ } } - // Calculate current Max HP level: - static csWeakRef<MathScript> maxHPScript; - - if(!maxHPScript) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(maxHPScript, "CalculateMaxHP"); - CS_ASSERT(maxHPScript.IsValid()); - } - if(overrideMaxHp) { GetMaxHP().SetBase(overrideMaxHp); } - else if(maxHPScript.IsValid()) + else { - maxHPScript->Evaluate(&env); + (void) psserver->GetCacheManager()->GetMaxHPScript()->Evaluate(&env); MathVar* maxHP = env.Lookup("MaxHP"); GetMaxHP().SetBase(maxHP->GetValue()); } @@ -3332,10 +3043,6 @@ // Stamina CalculateMaxStamina(); - - // Speed -// if (GetActor()) -// GetActor()->UpdateAllSpeedModifiers(); } size_t psCharacter::GetAssignedGMEvents(psGMEventListMessage &gmeventsMsg, int clientnum) Modified: trunk/src/server/bulkobjects/pscharacter.h =================================================================== --- trunk/src/server/bulkobjects/pscharacter.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/pscharacter.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -23,7 +23,6 @@ // Crystal Space Includes //============================================================================= #include <csutil/sysfunc.h> -#include <csutil/weakref.h> //============================================================================= // Project Includes @@ -1749,20 +1748,6 @@ Multiplier attackModifier; ///< Attack value is multiplied by this Multiplier defenseModifier; ///< Defense value is multiplied by this - - static csWeakRef<MathScript> maxRealmScript; - static csWeakRef<MathScript> staminaCalc; ///< The stamina calc script - static csWeakRef<MathScript> expSkillCalc; ///< The exp calc script to assign experience on skill ranking - static csWeakRef<MathScript> staminaRatioWalk; ///< The stamina regen ration while walking script - static csWeakRef<MathScript> staminaRatioStill;///< The stamina regen ration while standing script - static csWeakRef<MathScript> staminaRatioSit; ///< The stamina regen ration while sitting script - static csWeakRef<MathScript> staminaRatioWork; ///< The stamina regen ration while working script - static csWeakRef<MathScript> dodgeValueCalc; ///< Script for calculating dodge value. - static csWeakRef<MathScript> armorSkillsPractice; ///< Script to set the practice points for armor skills. - static csWeakRef<MathScript> charLevelGet; ///< Script to get the current char level - static csWeakRef<MathScript> skillValuesGet; ///< Script to get the current skill values - static csWeakRef<MathScript> baseSkillValuesGet; ///< Script to get the base skill values - st_location spawnLoc; csString name; Modified: trunk/src/server/bulkobjects/pscharinventory.cpp =================================================================== --- trunk/src/server/bulkobjects/pscharinventory.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/pscharinventory.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -194,40 +194,33 @@ void psCharacterInventory::CalculateLimits() { + CacheManager* cachemgr = psserver->GetCacheManager(); MathEnvironment env; // safe enough to reuse it for both...faster... env.Define("Actor", owner); // The max total weight that a player can carry - static csWeakRef<MathScript> maxCarryWeight = NULL; - if(psserver->GetMathScriptEngine()->CheckAndUpdateScript(maxCarryWeight, "CalculateMaxCarryWeight")) + (void) cachemgr->GetMaxCarryWeight()->Evaluate(&env); + MathVar* carry = env.Lookup("MaxCarry"); + if(carry) { - maxCarryWeight->Evaluate(&env); - MathVar* carry = env.Lookup("MaxCarry"); - if(carry) - { - maxWeight = carry->GetValue(); - } - else - { - Error1("Failed to evaluate MathScript >CalculateMaxCarryWeight<."); - } + maxWeight = carry->GetValue(); } + else + { + Error1("Failed to evaluate MathScript >CalculateMaxCarryWeight<."); + } // The max total size that a player can carry - static csWeakRef<MathScript> maxCarryAmount = NULL; - if(psserver->GetMathScriptEngine()->CheckAndUpdateScript(maxCarryAmount, "CalculateMaxCarryAmount")) + (void) cachemgr->GetMaxCarryAmount()->Evaluate(&env); + carry = env.Lookup("MaxAmount"); + if(carry) { - maxCarryAmount->Evaluate(&env); - MathVar* carry = env.Lookup("MaxAmount"); - if(carry) - { - maxSize = carry->GetValue(); - } - else - { - Error1("Failed to evaluate MathScript >CalculateMaxCarryAmount<."); - } + maxSize = carry->GetValue(); } + else + { + Error1("Failed to evaluate MathScript >CalculateMaxCarryAmount<."); + } UpdateEncumbrance(); } Modified: trunk/src/server/bulkobjects/psitem.cpp =================================================================== --- trunk/src/server/bulkobjects/psitem.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/psitem.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -1965,21 +1965,13 @@ psMoney psItem::GetPrice() { - static csWeakRef<MathScript> script; - if(!script.IsValid()) - psserver->GetMathScriptEngine()->CheckAndUpdateScript(script, "Calc Item Price"); - if(!script) - { - Error1("Cannot find mathscript: Calc Item Price"); - return current_stats->GetPrice(); - } MathEnvironment env; env.Define("Price", itemModifiers->active ? itemModifiers->price.GetTotal() : current_stats->GetPrice().GetTotal()); env.Define("Quality", GetItemQuality()); env.Define("MaxQuality", GetMaxItemQuality()); env.Define("BaseQuality", current_stats->GetQuality()); - script->Evaluate(&env); + (void) psserver->GetCacheManager()->GetCalcItemPrice()->Evaluate(&env); MathVar* finalPrice = env.Lookup("FinalPrice"); if(!finalPrice) @@ -1992,26 +1984,12 @@ psMoney psItem::GetSellPrice() { - static csWeakRef<MathScript> script; - if(!script.IsValid()) - psserver->GetMathScriptEngine()->CheckAndUpdateScript(script, "Calc Item Sell Price"); - if(!script) - { - Error1("Cannot find mathscript: Calc Item Sell Price"); - int sellPrice = (int)(GetPrice().GetTotal() * 0.8); - if(sellPrice == 0) - { - sellPrice = 1; - } - return sellPrice; - } - MathEnvironment env; env.Define("Price", GetPrice().GetTotal()); env.Define("Quality", GetItemQuality()); env.Define("MaxQuality", GetMaxItemQuality()); env.Define("BaseQuality", current_stats->GetQuality()); - script->Evaluate(&env); + (void) psserver->GetCacheManager()->GetCalcItemSellPrice()->Evaluate(&env); MathVar* finalPrice = env.Lookup("FinalPrice"); if(!finalPrice) @@ -3421,20 +3399,11 @@ void psItem::SendSketchDefinition(Client* client) { - // Get character capabilities - static csWeakRef<MathScript> script; - if(!script.IsValid()) - psserver->GetMathScriptEngine()->CheckAndUpdateScript(script, "Calc Player Sketch Limits"); - if(!script) - { - Error1("Cannot find mathscript: Calc Player Sketch Limits"); - return; - } - MathEnvironment env; env.Define("Actor", client->GetCharacterData()); - script->Evaluate(&env); + (void) psserver->GetCacheManager()->GetPlayerSketchLimits()->Evaluate(&env); + MathVar* score = env.Lookup("IconScore"); MathVar* count = env.Lookup("PrimCount"); CS_ASSERT(score && count); Modified: trunk/src/server/bulkobjects/psminigameboard.h =================================================================== --- trunk/src/server/bulkobjects/psminigameboard.h 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/psminigameboard.h 2014-03-07 21:05:39 UTC (rev 9323) @@ -23,7 +23,6 @@ //============================================================================= // Crystal Space Includes //============================================================================= -#include <csutil/weakref.h> //============================================================================= // Project Includes Modified: trunk/src/server/bulkobjects/psnpcloader.cpp =================================================================== --- trunk/src/server/bulkobjects/psnpcloader.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/psnpcloader.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -436,9 +436,6 @@ return; } - csWeakRef<MathScript> setBaseSkillsScript; - psserver->GetMathScriptEngine()->CheckAndUpdateScript(setBaseSkillsScript, "SetBaseSkills"); - MathEnvironment env; env.Define("Actor", npc); env.Define("STR", xmlnode->GetAttributeValueAsFloat("agi")); @@ -448,7 +445,7 @@ env.Define("WILL", xmlnode->GetAttributeValueAsFloat("str")); env.Define("CHA", xmlnode->GetAttributeValueAsFloat("wil")); - setBaseSkillsScript->Evaluate(&env); + psserver->GetCacheManager()->GetSetBaseSkillsScript()->Evaluate(&env); } Modified: trunk/src/server/bulkobjects/psspell.cpp =================================================================== --- trunk/src/server/bulkobjects/psspell.cpp 2014-03-07 18:42:23 UTC (rev 9322) +++ trunk/src/server/bulkobjects/psspell.cpp 2014-03-07 21:05:39 UTC (rev 9323) @@ -155,19 +155,13 @@ float psSpell::PowerLevel(psCharacter* caster, float kFactor) const { - static csWeakRef<MathScript> script = NULL; - if(!script.IsValid()) - { - psserver->GetMathScriptEngine()->CheckAndUpdateScript(script, "CalculatePowerLevel"); - CS_ASSERT(script.IsValid()); - } - MathEnvironment env; env.Define("RelatedStat", caster->GetSkillRank(way->related_stat_skill).Current()); env.Define("KFactor", kFactor); env.Define("WaySkill", caster->GetSkillRank(way->skill).Current()); - script->Evaluate(&env); + (void) psserver->GetCacheManager()->GetSpellPowerLevel()->Evaluate(&env); + MathVar* power = env.Lookup("PowerLevel"); CS_ASSERT(power); return power->GetValue(); @@ -175,13 +169,6 @@ psSpellCost psSpell::ManaCost... [truncated message content] |
From: <ral...@us...> - 2014-04-07 23:47:10
|
Revision: 9374 http://sourceforge.net/p/planeshift/code/9374 Author: ralphcampbell Date: 2014-04-07 23:47:07 +0000 (Mon, 07 Apr 2014) Log Message: ----------- Fix database 'pieces' parsing for single player games (puzzles) and double click to switch pieces. Modified Paths: -------------- trunk/src/client/gui/pawsgameboard.cpp trunk/src/common/net/messages.cpp trunk/src/common/net/messages.h trunk/src/common/util/minigame.h trunk/src/server/bulkobjects/psminigameboard.cpp trunk/src/server/bulkobjects/psminigameboard.h Modified: trunk/src/client/gui/pawsgameboard.cpp =================================================================== --- trunk/src/client/gui/pawsgameboard.cpp 2014-04-07 23:43:16 UTC (rev 9373) +++ trunk/src/client/gui/pawsgameboard.cpp 2014-04-07 23:47:07 UTC (rev 9374) @@ -561,8 +561,9 @@ // Use the EntitySelect mouse bind to select pieces/create player's pieces if (psengine->GetMouseBinds()->CheckBind("EntitySelect", button, modifiers)) { - if (pawsGameTile *tile = dynamic_cast<pawsGameTile *> - (PawsManager::GetSingleton().GetDragDropWidget())) + pawsGameTile *tile = dynamic_cast<pawsGameTile *> + (PawsManager::GetSingleton().GetDragDropWidget()); + if (tile) { SetState(tile->GetState()); board->DropPiece(this); @@ -573,7 +574,7 @@ board->BlackPiecesList(0) : board->WhitePiecesList(0)); board->UpdatePiece(this); } - else + else if (!(board->GetGameOptions() & OPTION_PLACE_ONLY)) { board->StartDragging(this); SetState(EMPTY_TILE); Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2014-04-07 23:43:16 UTC (rev 9373) +++ trunk/src/common/net/messages.cpp 2014-04-07 23:47:07 UTC (rev 9374) @@ -7773,7 +7773,8 @@ psMGBoardMessage::psMGBoardMessage(uint32_t client, uint8_t counter, uint32_t gameID, uint16_t options, int8_t cols, int8_t rows, uint8_t* layout, - uint8_t numOfPieces, uint8_t* pieces) + uint8_t numOfPieces, uint8_t piecesSize, + uint8_t* pieces) : msgLayout(0) { // We need tiles/2 number of bytes and one extra byte for odd number of tiles @@ -7781,10 +7782,6 @@ if(cols * rows % 2 != 0) layoutSize++; - int piecesSize = numOfPieces / 2; - if(numOfPieces % 2 != 0) - piecesSize++; - msg.AttachNew(new MsgEntry( sizeof(uint8_t) + // counter sizeof(uint32_t) + // game ID Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2014-04-07 23:43:16 UTC (rev 9373) +++ trunk/src/common/net/messages.h 2014-04-07 23:47:07 UTC (rev 9374) @@ -5605,7 +5605,7 @@ public: psMGBoardMessage(uint32_t client, uint8_t counter, uint32_t gameID, uint16_t options, int8_t cols, int8_t rows, uint8_t* layout, - uint8_t numOfPieces, uint8_t* pieces); + uint8_t numOfPieces, uint8_t piecesSize, uint8_t* pieces); psMGBoardMessage(MsgEntry* me); Modified: trunk/src/common/util/minigame.h =================================================================== --- trunk/src/common/util/minigame.h 2014-04-07 23:43:16 UTC (rev 9373) +++ trunk/src/common/util/minigame.h 2014-04-07 23:47:07 UTC (rev 9374) @@ -46,7 +46,8 @@ BLACK_SQUARE = 0x10, ///< Top left/all squares Black. Else white. PLAIN_SQUARES = 0x20, ///< Board squares all plain. Else checked. DISALLOWED_MOVE = 0x40, ///< Last move disallowed - OBSERVE_ENDGAME = 0x80 ///< observe endgame play + OBSERVE_ENDGAME = 0x80, ///< observe endgame play + OPTION_PLACE_ONLY = 0x8000 ///< don't pick up pieces }; /// Minigame tile state values Modified: trunk/src/server/bulkobjects/psminigameboard.cpp =================================================================== --- trunk/src/server/bulkobjects/psminigameboard.cpp 2014-04-07 23:43:16 UTC (rev 9373) +++ trunk/src/server/bulkobjects/psminigameboard.cpp 2014-04-07 23:47:07 UTC (rev 9374) @@ -60,13 +60,11 @@ // Get the list of available pieces pieces = NULL; - uint8_t numPieces = 0; + numPieces = 0; // Pack the list of pieces numPieces = (uint8_t)strlen(piecesStr); - size_t piecesSize = numPieces / 2; - if(numPieces % 2) - piecesSize++; + piecesSize = (numPieces + 1) / 2; pieces = new uint8_t[piecesSize]; Modified: trunk/src/server/bulkobjects/psminigameboard.h =================================================================== --- trunk/src/server/bulkobjects/psminigameboard.h 2014-04-07 23:43:16 UTC (rev 9373) +++ trunk/src/server/bulkobjects/psminigameboard.h 2014-04-07 23:47:07 UTC (rev 9374) @@ -183,6 +183,9 @@ /// The number of available pieces. uint8_t numPieces; + /// The number of available pieces. + uint8_t piecesSize; + /// The package list of available game pieces. uint8_t* pieces; @@ -247,6 +250,12 @@ return gameBoardDef->numPieces; } + /// Returns the number of available pieces. + uint8_t GetPiecesSize() const + { + return gameBoardDef->piecesSize; + } + /// Returns the package list of available pieces. uint8_t* GetPieces() const { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2014-04-09 17:54:21
|
Revision: 9381 http://sourceforge.net/p/planeshift/code/9381 Author: ralphcampbell Date: 2014-04-09 17:54:16 +0000 (Wed, 09 Apr 2014) Log Message: ----------- Major update to the new combat system. Changes include: Merging default, melee, and ranged code into common code which is controlled by the database entries. The attacks.sql table replaces 'speed' and 'successchance' with 'damage', a mathscript which defines an environment which can be used by the range, aoe_radius, and aoe_angle MathExpressions. Also, 'form' is replaced with 'delay' which is a MathScript to compute the delay before the attack "happens". MathScripts can now reference the combat_stance table: stamina_drain_p, stamina_drain_m, attack_speed_mod, attack_damage_mod, defense_avoid_mod, and defense_absorb_mod. For example, "Attacker:defense_absorb_mod" where Attacker is a gemActor environment variable. Modified Paths: -------------- trunk/src/common/util/mathscript.cpp trunk/src/server/bulkobjects/psattack.cpp trunk/src/server/bulkobjects/psattack.h trunk/src/server/bulkobjects/psattackqueue.cpp trunk/src/server/bulkobjects/psattackqueue.h trunk/src/server/bulkobjects/pscharacter.cpp trunk/src/server/bulkobjects/psitem.cpp trunk/src/server/bulkobjects/psquestprereqops.cpp trunk/src/server/bulkobjects/psquestprereqops.h trunk/src/server/cachemanager.cpp trunk/src/server/cachemanager.h trunk/src/server/combatmanager.cpp trunk/src/server/combatmanager.h trunk/src/server/database/mysql/attack_types.sql trunk/src/server/database/mysql/attacks.sql trunk/src/server/database/mysql/math_scripts.sql trunk/src/server/gem.cpp trunk/src/server/gem.h trunk/src/server/npcmanager.cpp trunk/src/server/progressionmanager.h trunk/src/server/usermanager.cpp Removed Paths: ------------- trunk/src/server/bulkobjects/psattackdefault.cpp trunk/src/server/bulkobjects/psattackdefault.h trunk/src/server/bulkobjects/psattackmelee.cpp trunk/src/server/bulkobjects/psattackmelee.h trunk/src/server/bulkobjects/psattackrange.cpp trunk/src/server/bulkobjects/psattackrange.h Modified: trunk/src/common/util/mathscript.cpp =================================================================== --- trunk/src/common/util/mathscript.cpp 2014-04-09 13:58:39 UTC (rev 9380) +++ trunk/src/common/util/mathscript.cpp 2014-04-09 17:54:16 UTC (rev 9381) @@ -903,7 +903,7 @@ MathExpression* exp = new MathExpression; exp->name = name; - if (!exp->Parse(expression)) + if (!expression || expression[0] == '\0' || !exp->Parse(expression)) { delete exp; return NULL; Modified: trunk/src/server/bulkobjects/psattack.cpp =================================================================== --- trunk/src/server/bulkobjects/psattack.cpp 2014-04-09 13:58:39 UTC (rev 9380) +++ trunk/src/server/bulkobjects/psattack.cpp 2014-04-09 17:54:16 UTC (rev 9381) @@ -26,6 +26,7 @@ #include <iutil/document.h> #include <csutil/xmltiny.h> #include <csgeom/math.h> +#include <csgeom/math3d.h> //============================================================================= // Project Includes @@ -33,6 +34,7 @@ #include "util/log.h" #include "util/mathscript.h" #include "util/psdatabase.h" +#include "engine/psworld.h" #include "psserver.h" #include "gem.h" @@ -43,6 +45,7 @@ #include "progressionmanager.h" #include "combatmanager.h" #include "npcmanager.h" +#include "psserverchar.h" #include "../globals.h" #include "scripting.h" @@ -51,36 +54,648 @@ //============================================================================= #include "psquestprereqops.h" +/**********************************************************************************************************/ +psAttack::psAttack() : + attackRange(0), + aoeRadius(0), + aoeAngle(0) +{ +} -/**********************************************************************************************************/ +psAttack::~psAttack() +{ + delete attackRange; + delete aoeRadius; + delete aoeAngle; +} -psCombatAttackGameEvent::psCombatAttackGameEvent(int delayticks, +bool psAttack::Load(iResultRow& row) +{ + id = row.GetInt("id"); + name = row["name"]; + image = row["image_name"]; + animation = row["attack_anim"]; + description = row["attack_description"]; + + MathScriptEngine* mse = psserver->GetMathScriptEngine(); + damage_script = mse->FindScript(row["damage"]); + attackDelay = mse->FindScript(row["delay"]); + if(!damage_script || !attackDelay) + return false; + + type = psserver->GetCacheManager()->GetAttackTypeByName(row["attackType"]); + + attackRange = MathExpression::Create(row["range"], "attackRange"); + aoeRadius = MathExpression::Create(row["aoe_radius"], "aoeRadius"); + aoeAngle = MathExpression::Create(row["aoe_angle"], "aoeAngle"); + outcome = psserver->GetProgressionManager()->FindScript(row["outcome"]); + + const char* req = row["requirements"]; + if(req && req[0] && !LoadPrerequisiteXML(requirements, NULL, req)) + { + return false; + } + + if(type) + TypeRequirements.AttachNew(new psPrereqOpAttackType(type)); + return true; +} + +bool psAttack::CanAttack(Client* client) +{ + if(TypeRequirements) + { + if(!TypeRequirements->Check(client->GetCharacterData())) + return false; + } + if(requirements) + { + return requirements->Check(client->GetCharacterData()); + } + return true; +} + +bool psAttack::Attack(gemActor* attacker, gemActor* target, INVENTORY_SLOT_NUMBER slot) +{ + psCharacter* character = attacker->GetCharacterData(); + psItem* weapon = character->Inventory().GetEffectiveWeaponInSlot(slot); + float latency = weapon->GetLatency(); + + float dist; + { + csVector3 attackerPos, targetPos; + iSector* attackerSector, *targetSector; + + attacker->GetPosition(attackerPos, attackerSector); + target->GetPosition(targetPos, targetSector); + + if((attacker->GetInstance() != target->GetInstance() && + attacker->GetInstance() != INSTANCE_ALL && + target->GetInstance() != INSTANCE_ALL) || + !(EntityManager::GetSingleton().GetWorld()->WarpSpace(targetSector, attackerSector, targetPos))) + { + return false; + } + dist = sqrtf(csSquaredDist::PointPoint(targetPos, attackerPos)); + } + + MathEnvironment env; + env.Define("Latency", latency); + env.Define("Distance", dist); + attackDelay->Evaluate(&env); + MathVar* result = env.Lookup("Result"); + csTicks delay = (csTicks)result->GetRoundValue(); + + psCombatAttackGameEvent* event = + new psCombatAttackGameEvent(delay, this, attacker, target, slot, weapon); + character->TagEquipmentObject(slot, event->id); + psserver->GetEventManager()->Push(event); + + return true; +} + +void psAttack::Affect(psCombatAttackGameEvent* event) +{ + gemActor* attacker = event->GetAttacker(); + gemActor* target = event->GetTarget(); + if(!attacker || !target) + { + Debug2(LOG_COMBAT,event->GetAttackerID(),"Attacker ID: %d. Combat stopped as one participant logged off.",event->GetAttackerID()); + return; + } + + // If the attacker is no longer in attack mode, abort. + if(attacker->GetMode() != PSCHARACTER_MODE_COMBAT) + { + Debug2(LOG_COMBAT,event->GetAttackerID(),"Combat stopped as attacker %d left combat mode.",event->GetAttackerID()); + return; + } + + // If target is dead, abort. + if(!target->IsAlive()) + { + Debug2(LOG_COMBAT,event->GetAttackerID(),"Combat stopped as target %d is dead.",event->GetTargetID()); + psserver->GetCombatManager()->StopAttack(attacker); + return; + } + + // If the slot is no longer attackable, abort + psCharacter* attacker_data = attacker->GetCharacterData(); + INVENTORY_SLOT_NUMBER slot = event->GetWeaponSlot(); + if(!attacker_data->Inventory().CanItemAttack(slot)) + { + Debug2(LOG_COMBAT,event->GetAttackerID(),"Combat stopped as attacker no longer has an attacking item equipped. Attacker ID: %d",event->GetAttackerID()); + psserver->GetCombatManager()->StopAttack(attacker); + return; + } + + psItem* weapon = attacker_data->Inventory().GetEffectiveWeaponInSlot(slot); + + // weapon became unwieldable + csString response; + if(weapon && !weapon->CheckRequirements(attacker_data, response)) + { + Debug2(LOG_COMBAT, event->GetAttackerID(), "%s has lost use of weapon", attacker->GetName()); + psserver->GetCombatManager()->StopAttack(attacker); + psserver->SendSystemError(event->GetAttackerID(), "You can't use your %s any more.", weapon->GetName()); + return; + } + + Client* attacker_client = attacker->GetClient(); + if(attacker_client) + { + // Input the stamina data + MathEnvironment env; + env.Define("Actor", event->GetAttacker()); + env.Define("Weapon", weapon); + + (void) psserver->GetCacheManager()->GetStaminaCombat()->Evaluate(&env); + + MathVar* PhyDrain = env.Lookup("PhyDrain"); + MathVar* MntDrain = env.Lookup("MntDrain"); + + // stop the attack if the attacker has no stamina left + if((attacker_data->GetStamina(true) < PhyDrain->GetValue()) || + (attacker_data->GetStamina(false) < MntDrain->GetValue())) + { + psserver->GetCombatManager()->StopAttack(attacker); + psserver->SendSystemError(event->GetAttackerID(), "You are too tired to attack."); + return; + } + + // If the target has become impervious, abort and give up attacking + csString msg; + if(!attacker->IsAllowedToAttack(target, msg)) + { + psserver->GetCombatManager()->StopAttack(attacker); + return; + } + + //I will be seeing how this affects things and make changes accordingly + // If the target has changed, abort (assume another combat event has started since we are still in attack mode) + if(target != attacker_client->GetTargetObject()) + { + Debug2(LOG_COMBAT,event->GetAttackerID(),"Skipping attack, Target changed for attacker ID: %d.",event->GetAttackerID()); + return; + } + } + else + { + // Check if the npc's target has changed (if it has, then assume another combat event has started.) + gemNPC* npcAttacker = attacker->GetNPCPtr(); + if(npcAttacker && npcAttacker->GetTarget() != target) + { + Debug2(LOG_COMBAT,event->GetAttackerID(),"Skipping attack, Target changed for attacker ID: %d.",event->GetAttackerID()); + return; + } + } + + // If the weapon in the slot has been changed, + // skip a turn (latency for this slot may also have changed). + if(event->GetWeapon() != weapon) + { + Debug2(LOG_COMBAT, attacker->GetClientID(), "Skipping attack because %s has changed weapons mid battle", attacker->GetName()); + } + else if(attacker->IsSpellCasting()) + { + psserver->SendSystemInfo(event->GetAttackerID(), "You can't attack while casting spells."); + } + else + { + int attack_result; + + if(weapon->GetIsRangeWeapon() && weapon->GetUsesAmmo()) + { + INVENTORY_SLOT_NUMBER otherHand = + event->GetWeaponSlot() == PSCHARACTER_SLOT_RIGHTHAND ? + PSCHARACTER_SLOT_LEFTHAND: PSCHARACTER_SLOT_RIGHTHAND; + psItem* otherItem = attacker_data->Inventory().GetInventoryItem(otherHand); + if(otherItem == NULL) + { + attack_result = ATTACK_OUTOFAMMO; + } + else if(otherItem->GetIsContainer()) // Is it a quiver? + { + // Pick the first ammo we can shoot from the container + // And set it as the active ammo + attack_result = ATTACK_OUTOFAMMO; + for(size_t i=1; i<attacker_data->Inventory().GetInventoryIndexCount(); i++) + { + psItem* currItem = attacker_data->Inventory().GetInventoryIndexItem(i); + if(currItem && + currItem->GetContainerID() == otherItem->GetUID() && + weapon->GetAmmoTypeID().In(currItem->GetBaseStats()->GetUID())) + { + otherItem = currItem; + attack_result = ATTACK_NOTCALCULATED; + break; + } + } + } + else if(!weapon->GetAmmoTypeID().In(otherItem->GetBaseStats()->GetUID())) + { + attack_result = ATTACK_OUTOFAMMO; + } + + if(attack_result != ATTACK_OUTOFAMMO) + { + psItem* usedAmmo = attacker_data->Inventory().RemoveItemID(otherItem->GetUID(), 1); + if(usedAmmo) + { + attack_result = CalculateAttack(event, usedAmmo); + usedAmmo->Destroy(); + psserver->GetCharManager()->UpdateItemViews(attacker_client->GetClientNum()); + } + else + attack_result = CalculateAttack(event); + } + } + else + { + attack_result = CalculateAttack(event); + } + + int affectedCount = 0; + float radius = aoeRadius->Evaluate(&event->env); + if(radius < 0.01f) // single target + { + AffectTarget(target, event, attack_result); + affectedCount++; + } + else // AOE (Area of Effect) + { + csVector3 attackerPos; + csVector3 targetPos; + iSector* attackerSector, *targetSector; + InstanceID targetInstance = target->GetInstance(); + + attacker->GetPosition(attackerPos, attackerSector); + target->GetPosition(targetPos, targetSector); + + // directional vector for a line from attacker to original target + csVector3 attackerToTarget; + attackerToTarget = targetPos - attackerPos; + + float angle = aoeAngle->Evaluate(&event->env); + if(angle <= SMALL_EPSILON || angle > 360) + angle = 360; + angle = (angle/2)*(PI/180); // convert degrees to radians + + csArray<gemObject*> nearby = psserver->entitymanager->GetGEM()->FindNearbyEntities(targetSector, targetPos, targetInstance, radius); + for(size_t i = 0; i < nearby.GetSize(); i++) + { + gemActor* nearby_target = nearby[i]->GetActorPtr(); + csString msg; + if(!attacker->IsAllowedToAttack(nearby_target, msg)) + continue; + + if(angle < PI) + { + csVector3 attackerToAffected = nearby_target->GetPosition(); + + // obtain a directional line for the vector from attacker to affacted target + // note that this line does not originate at the original target because the + // cone that shall include the hittable area shall originate at the attacker + attackerToAffected -= attackerPos; + + // Angle between the line original target->attacker and original target->affected target + float cosATAngle = (attackerToAffected * attackerToTarget) / + (attackerToAffected.Norm() * attackerToTarget.Norm()); + + // cap the value to meaningful ones to account for rounding issues + if(cosATAngle > 1.0f || CS::IsNaN(cosATAngle)) + cosATAngle = 1.0f; + if(cosATAngle < -1.0f) + cosATAngle = -1.0f; + + // use the absolute value of the angle here to account + // for both sides equally - see above + if(fabs(acosf(cosATAngle)) >= angle) + continue; + } + + // XXX recompute attack_result? + AffectTarget(nearby_target, event, attack_result); + affectedCount++; + } + + if(affectedCount > 0) + { + psserver->SendSystemInfo(attacker->GetClientID(), + "%s affected %d %s.", + name.GetData(), affectedCount, + (affectedCount == 1) ? "target" : "targets"); + } + else + { + psserver->SendSystemInfo(attacker->GetClientID(), "%s has no effect.", name.GetData()); + } + } + + // Get the next special attack to execute. + psAttack* attack = attacker_data->GetAttackQueue()->First(); + if(!attack || !attack->CanAttack(attacker_client)) + { + // Use the default attack type. + attack = psserver->GetCacheManager()->GetAttackByID(1); + } + + // Schedule the next attack. + attack->Attack(attacker, target, slot); + } +} + +int psAttack::CalculateAttack(psCombatAttackGameEvent* event, psItem* subWeapon) +{ + INVENTORY_SLOT_NUMBER otherHand = + event->GetWeaponSlot() == PSCHARACTER_SLOT_LEFTHAND ? + PSCHARACTER_SLOT_RIGHTHAND : PSCHARACTER_SLOT_LEFTHAND; + event->AttackLocation = (INVENTORY_SLOT_NUMBER) psserver->GetCombatManager()->targetLocations[psserver->rng->Get((int) psserver->GetCombatManager()->targetLocations.GetSize())]; + + gemActor* attacker = event->GetAttacker(); + gemActor* target = event->GetTarget(); + psCharacter* attacker_data = attacker->GetCharacterData(); + psCharacter* target_data = target->GetCharacterData(); + + // calculate difference between target and attacker location - to be used for angle validation + csVector3 diff; + { + csVector3 attackerPos, targetPos; + iSector* attackerSector, *targetSector; + + attacker->GetPosition(attackerPos, attackerSector); + target->GetPosition(targetPos, targetSector); + + if((attacker->GetInstance() != target->GetInstance() && + attacker->GetInstance() != INSTANCE_ALL && + target->GetInstance() != INSTANCE_ALL) || + !(EntityManager::GetSingleton().GetWorld()->WarpSpace(targetSector, attackerSector, targetPos))) + { + return ATTACK_OUTOFRANGE; + } + diff = targetPos - attackerPos; + } + + MathEnvironment& env(event->env); + env.Define("Attacker", attacker); + env.Define("Target", target); + env.Define("OrigTarget", target); + env.Define("AttackWeapon", event->GetWeapon()); + env.Define("AttackWeaponSecondary", subWeapon); + env.Define("TargetWeapon", target_data->Inventory().GetEffectiveWeaponInSlot(event->GetWeaponSlot(), true)); + env.Define("TargetWeaponSecondary", target_data->Inventory().GetEffectiveWeaponInSlot(otherHand, true)); + env.Define("AttackLocationItem", target_data->Inventory().GetEffectiveArmorInSlot(event->AttackLocation)); + env.Define("DiffX", diff.x ? diff.x : 0.00001F); // force minimal value + env.Define("DiffY", diff.y ? diff.y : 0.00001F); // force minimal value + env.Define("DiffZ", diff.z ? diff.z : 0.00001F); // force minimal value + env.Define("RelatedStat", type ? + attacker_data->GetSkillRank(type->related_stat).Current() : 0); + + float range = attackRange ? attackRange->Evaluate(&env) : 0.0; + env.Define("Range", range); + + (void) damage_script->Evaluate(&env); + + if(DoLogDebug2(LOG_COMBAT, event->GetAttackerID())) + { + CPrintf(CON_DEBUG, "Variables for Calculate Damage:\n"); + env.DumpAllVars(); + } + + MathVar* badrange = env.Lookup("BadRange"); // BadRange = Target is too far away + MathVar* badangle = env.Lookup("BadAngle"); // BadAngle = Attacker doesn't aim at enemy + MathVar* missed = env.Lookup("Missed"); // Missed = Attack missed the enemy + MathVar* dodged = env.Lookup("Dodged"); // Dodged = Attack dodged by enemy + MathVar* blocked = env.Lookup("Blocked"); // Blocked = Attack blocked by enemy + MathVar* damage = env.Lookup("FinalDamage"); // Actual damage done, if any + + if(badrange && badrange->GetValue() < 0.0) + return ATTACK_OUTOFRANGE; + else if(badangle && badangle->GetValue() < 0.0) + return ATTACK_BADANGLE; + else if(missed && missed->GetValue() < 0.0) + return ATTACK_MISSED; + else if(dodged && dodged->GetValue() < 0.0) + return ATTACK_DODGED; + else if(blocked && blocked->GetValue() < 0.0) + return ATTACK_BLOCKED; + + event->FinalDamage = damage->GetValue(); + + return ATTACK_DAMAGE; +} + +void psAttack::AffectTarget(gemActor* target, psCombatAttackGameEvent* event, int attack_result) +{ + // Redefine the target + event->env.Define("Target", target); + + gemActor* attacker = event->GetAttacker(); + psCharacter* attacker_data = attacker->GetCharacterData(); + psCharacter* target_data = target->GetCharacterData(); + + MathVar* weaponDecay = NULL; + MathVar* blockDecay = NULL; + MathVar* armorDecay = NULL; + + psItem* weapon = event->GetWeapon(); + psItem* blockingWeapon = target_data->Inventory().GetEffectiveWeaponInSlot(event->GetWeaponSlot(), true); + psItem* struckArmor = target_data->Inventory().GetEffectiveArmorInSlot(event->AttackLocation); + + // there may only be a decay if you actually hit your target by some means + if(attack_result == ATTACK_DAMAGE || attack_result == ATTACK_BLOCKED) + { + // We are guaranteed some armor is present: + // real one, race one or base one. + CS_ASSERT(struckArmor); + float ArmorVsWeapon = weapon->GetArmorVSWeaponResistance(struckArmor->GetBaseStats()); + + // clamp value between 0 and 1 + ArmorVsWeapon = ArmorVsWeapon > 1.0F ? 1.0F : ArmorVsWeapon < 0.0F ? 0.0F : ArmorVsWeapon; + + MathEnvironment& env(event->env); + env.Define("Weapon", weapon); // weapon used in the attack + env.Define("BlockingWeapon", blockingWeapon); // weapon that blocked the attack + env.Define("Armor", struckArmor); // armor hit + env.Define("ArmorVsWeapon", ArmorVsWeapon); // armor vs weapon effectiveness + env.Define("Blocked", (attack_result == ATTACK_BLOCKED)); // identifies whether this attack was blocked + + (void) psserver->GetCacheManager()->GetCalcDecay()->Evaluate(&env); + + weaponDecay = env.Lookup("WeaponDecay"); + blockDecay = env.Lookup("BlockingDecay"); + armorDecay = env.Lookup("ArmorDecay"); + } + + switch(attack_result) + { + case ATTACK_DAMAGE: + { + bool isNearlyDead = false; + if(target_data->GetMaxHP().Current() > 0.0 && + target_data->GetHP()/target_data->GetMaxHP().Current() > 0.2) + { + if((target_data->GetHP() - event->FinalDamage) / target_data->GetMaxHP().Current() <= 0.2) + isNearlyDead = true; + } + + psCombatEventMessage ev(event->GetAttackerID(), + isNearlyDead ? psCombatEventMessage::COMBAT_DAMAGE_NEARLY_DEAD : psCombatEventMessage::COMBAT_DAMAGE, + attacker->GetEID(), + target->GetEID(), + event->AttackLocation, + event->FinalDamage, + weapon->GetAttackAnimID(attacker_data), + target->FindAnimIndex(animation)); + + ev.Multicast(target->GetMulticastClients(), 0, MAX_COMBAT_EVENT_RANGE); + + // Apply final damage + if(outcome) + outcome->Run(&event->env); + else + target->DoDamage(attacker, event->FinalDamage); + + attacker->InvokeAttackScripts(target, weapon); + target->InvokeDefenseScripts(attacker, weapon); + if(isNearlyDead) + { + target->InvokeNearlyDeadScripts(attacker, weapon); + } + + // If the target wasn't in combat, it is now... + // Note that other modes shouldn't be interrupted automatically + if(target->GetMode() == PSCHARACTER_MODE_PEACE || + target->GetMode() == PSCHARACTER_MODE_WORK) + { + if(target->GetClient()) // Set reciprocal target + { + target->GetClient()->SetTargetObject(attacker, true); + target->SendTargetStatDR(target->GetClient()); + } + + // The default stance is 'Fully Defensive'. + const Stance& initialStance(psserver->GetCombatManager()->GetStance(psserver->GetCacheManager(), "FullyDefensive")); + psserver->GetCombatManager()->AttackSomeone(target, attacker, initialStance); + } + + weapon->AddDecay(weaponDecay->GetValue()); + struckArmor->AddDecay(armorDecay->GetValue()); + + psserver->GetCombatManager()->NotifyTarget(attacker, target); + + break; + } + case ATTACK_DODGED: + { + psCombatEventMessage ev(event->GetAttackerID(), + psCombatEventMessage::COMBAT_DODGE, + attacker->GetEID(), + target->GetEID(), + event->AttackLocation, + 0, // no dmg on a dodge + weapon->GetAttackAnimID(attacker_data), + (unsigned int)-1); // no defense anims yet + + ev.Multicast(target->GetMulticastClients(), 0, MAX_COMBAT_EVENT_RANGE); + psserver->GetCombatManager()->NotifyTarget(attacker, target); + break; + } + case ATTACK_BLOCKED: + { + psCombatEventMessage ev(event->GetAttackerID(), + psCombatEventMessage::COMBAT_BLOCK, + attacker->GetEID(), + target->GetEID(), + event->AttackLocation, + 0, // no dmg on a block + weapon->GetAttackAnimID(attacker_data), + (unsigned int)-1); // no defense anims yet + + ev.Multicast(target->GetMulticastClients(),0,MAX_COMBAT_EVENT_RANGE); + + if(weapon) + { + weapon->AddDecay(weaponDecay->GetValue()); + } + //TODO: for now we disable decaying for bows (see PS#5181) + if(blockingWeapon && !blockingWeapon->GetIsRangeWeapon()) + { + blockingWeapon->AddDecay(blockDecay->GetValue()); + } + + psserver->GetCombatManager()->NotifyTarget(attacker,target); + + break; + } + case ATTACK_MISSED: + { + psCombatEventMessage ev(event->GetAttackerID(), + psCombatEventMessage::COMBAT_MISS, + attacker->GetEID(), + target->GetEID(), + event->AttackLocation, + 0, // no dmg on a miss + weapon->GetAttackAnimID(attacker_data), + (unsigned int)-1); // no defense anims yet + + ev.Multicast(target->GetMulticastClients(), 0, MAX_COMBAT_EVENT_RANGE); + psserver->GetCombatManager()->NotifyTarget(attacker, target); + break; + } + case ATTACK_OUTOFRANGE: + { + if(event->GetAttackerID()) + { + psserver->SendSystemError(event->GetAttackerID(),"You are too far away to attack!"); + + } + break; + } + case ATTACK_BADANGLE: + { + if(event->GetAttackerID()) // if human player + { + psserver->SendSystemError(event->GetAttackerID(),"You must face the enemy to attack!"); + + } + break; + } + case ATTACK_OUTOFAMMO: + { + psserver->SendSystemError(event->GetAttackerID(), "You are out of ammo!"); + + // If you run out of ammo, you exit attack mode. + psserver->GetCombatManager()->StopAttack(attacker); + break; + } + } +} + +psCombatAttackGameEvent::psCombatAttackGameEvent(csTicks delayticks, psAttack* attack, - gemObject* attacker, - gemObject* target, + gemActor* attacker, + gemActor* target, INVENTORY_SLOT_NUMBER weaponslot, - int attackerCID, - int targetCID) : psGameEvent(0,delayticks,"psCombatAttackGameEvent") + psItem* weapon) : + psGameEvent(0, delayticks, "psCombatAttackGameEvent") { + this->attack = attack; this->attacker = attacker; - this->attack = attack; this->target = target; - this->attackerdata = attacker->GetCharacterData(); - this->targetdata = target->GetCharacterData(); - this->WeaponSlot = weaponslot; - this->weapon = attackerdata->Inventory().GetEffectiveWeaponInSlot(weaponslot); - this->AttackerCID = attackerCID; - this->TargetCID = targetCID; + this->weaponSlot = weaponslot; + this->weapon = weapon; + this->AttackerCID = attacker->GetClientID(); + this->TargetCID = target->GetClientID(); - AttackLocation=PSCHARACTER_SLOT_NONE; - FinalDamage=-1; - AttackResult=ATTACK_NOTCALCULATED; + AttackLocation = PSCHARACTER_SLOT_NONE; + FinalDamage = -1; target->RegisterCallback(this); attacker->RegisterCallback(this); +} -} psCombatAttackGameEvent::~psCombatAttackGameEvent() { if(target) @@ -90,26 +705,35 @@ if(attacker) { attacker->UnregisterCallback(this); + if(attack && attack->GetID() != 1) + { + psCharacter* attacker_data = attacker->GetCharacterData(); + attacker_data->GetAttackQueue()->Pop(); + } } } + void psCombatAttackGameEvent::DeleteObjectCallback(iDeleteNotificationObject* object) { if(target) { target->UnregisterCallback(this); + target = NULL; } if(attacker) { attacker->UnregisterCallback(this); + attacker = NULL; } +} - target = NULL; - attacker = NULL; -} void psCombatAttackGameEvent::Trigger() { - if(!attacker.IsValid() || !target.IsValid()) - return; - - psserver->GetCombatManager()->HandleCombatEvent(this); + if(attack->GetID() != 1 && attacker) + { + psCharacter* attacker_data = attacker->GetCharacterData(); + attacker_data->GetAttackQueue()->Pop(); + } + attack->Affect(this); + attack = NULL; } Modified: trunk/src/server/bulkobjects/psattack.h =================================================================== --- trunk/src/server/bulkobjects/psattack.h 2014-04-09 13:58:39 UTC (rev 9380) +++ trunk/src/server/bulkobjects/psattack.h 2014-04-09 17:54:16 UTC (rev 9381) @@ -38,6 +38,7 @@ #include "psitemstats.h" #include "psitem.h" #include "deleteobjcallback.h" +#include "combatmanager.h" using namespace CS; @@ -45,7 +46,6 @@ class psCharacter; class psAttack; class Client; -class gemObject; class gemActor; class ProgressionScript; class MathExpression; @@ -68,41 +68,44 @@ }; - struct psAttackCost// may be expanded later if more balance is needed { float physStamina; }; - /** - * Represents an Attack. This is mostly data that is cached in from the - * database to represent what a attack is. It contains details such as the - * required glyphs as well as the effect of the spell. + * Represents an Attack. This is mostly data that is cached from the + * database to represent what an attack is. * - * This is going to be very close to how a spell works but more in touch with melee adn range style. + * This is going to be very close to how a spell works but more in touch with melee and range style. */ -class psAttack : public csRefCount +class psAttack : public csRefCount { public: + psAttack(); + ~psAttack(); - virtual bool Load(iResultRow &row) = 0; + /** + * Initialize the attack from the database entry. + */ + bool Load(iResultRow& row); - /** - * Calls an attack. + * This is a check to see if the attack can be used by the character. */ - virtual bool Attack(gemObject* attacker,gemObject* target,INVENTORY_SLOT_NUMBER slot) = 0; + bool CanAttack(Client* client); + /** - * Once the combat event is called, this meathod runs preattack checks and runs all calculations needed before the combat event is applied + * Schedules an attack. */ - virtual void Affect(psCombatAttackGameEvent* event) = 0; + bool Attack(gemActor* attacker, gemActor* target, INVENTORY_SLOT_NUMBER slot); + /** - * this is just a check to see if the attack can be used by the character + * Once the combat event is called, this meathod runs preattack checks + * and runs all calculations needed before the combat event is applied. */ - virtual bool CanAttack(Client* client) = 0; + virtual void Affect(psCombatAttackGameEvent* event); - /** gets the id * @return the attack id */ @@ -110,6 +113,7 @@ { return id; } + /** Gets the Name * @return returns the name of attack */ @@ -117,6 +121,7 @@ { return name; } + /** Gets the attack icon string *@return attack icon image string */ @@ -124,6 +129,7 @@ { return image; } + /** Gets the attack description * @return attack description */ @@ -132,33 +138,36 @@ return description; } - const float GetSpeed() const - { - return speed; - } - psAttackType* GetType() const { return type; } - virtual bool IsDualWield(psCharacter* attacker) = 0; - /** - * says if the attack has been queued from the UI as special attack - */ - virtual bool IsQueuedInClient() = 0; - protected: + int CalculateAttack(psCombatAttackGameEvent* event, psItem* subWeapon = NULL); + void AffectTarget(gemActor* target, psCombatAttackGameEvent* event, int attack_result); - int id; ///< The stored ID of the attack - csString name; ///< The stored name of the attack - csString image; ///< the address/id of the icon for the attack - csString description;///<the attack description - psAttackType* type; ///< the attack type - float speed; ///< the speed of the attack - //I am trying to figure out which members/variables should be given to "psattack" and which ones to only the children. so this will - // likely change a lot more + int id; ///< The stored ID of the attack + csString name; ///< The stored name of the attack + csString image; ///< the address/id of the icon for the attack + csString animation; ///< possible attack animation + csString description; ///<the attack description + psAttackType* type; ///< the attack type + csRef<psQuestPrereqOp> requirements; ///< all non weapon based attack requirements. + csRef<psQuestPrereqOp> TypeRequirements; ///< all Attack Type based requirements(not handled as a script) + /// Delay in milliseconds before attack "hits" or has an effect. + MathScript* attackDelay; + /// The Max Range of the attack (Meters) + MathExpression* attackRange; + /// AOE Radius: (Power, WaySkill, RelatedStat) -> Meters + MathExpression* aoeRadius; + /// AOE Angle: (Power, WaySkill, RelatedStat) -> Degrees + MathExpression* aoeAngle; + /// Chance of Success + MathScript* damage_script; + /// The progression script: (Power, Caster, Target) -> (side effects) + ProgressionScript* outcome; }; //----------------------------------------------------------------------------- @@ -169,79 +178,70 @@ class psCombatAttackGameEvent : public psGameEvent, public iDeleteObjectCallback { public: - csWeakRef<gemObject> attacker; ///< Entity who instigated this attack - csWeakRef<gemObject> target; ///< Entity who is target of this attack - psCharacter* attackerdata; ///< the attackers data - psCharacter* targetdata; ///< the targets data - int TargetCID; ///< ClientID of target - int AttackerCID; ///< ClientID of attacker - - float MaxRange; ///the maximum range the attack can reach - - psAttack* attack; ///< The attack - - INVENTORY_SLOT_NUMBER WeaponSlot; ///< Identifier of the slot for which this attack event should process - psItem* weapon; ///< the attacking weapon - - INVENTORY_SLOT_NUMBER AttackLocation; ///< Which slot should we check the armor of? - - float FinalDamage; ///< Final damage applied to target - - int AttackResult; ///< Code indicating the result of the attack attempt - int PreviousAttackResult; ///< The code of the previous result of the attack attempt - - float max_range; ///< the maximum range of the attack - float powerLevel; ///< the pwoer of the attack to be used in the final damage formula - - int attackAnim; ///< the attackers animation - int TargetAnim; ///< the targets animation, likely always going to be "hit" but could be something else... - - psCombatAttackGameEvent(int delayticks, + psCombatAttackGameEvent(csTicks delayticks, psAttack* attack, - gemObject* attacker, - gemObject* target, + gemActor* attacker, + gemActor* target, INVENTORY_SLOT_NUMBER weaponslot, - int attackerCID, - int targetCID); - ~psCombatAttackGameEvent(); + psItem* weapon); + virtual ~psCombatAttackGameEvent(); + virtual void Trigger(); // Abstract event processing function + virtual void DeleteObjectCallback(iDeleteNotificationObject* object); - gemObject* GetTarget() + psAttack* GetAttack() { - return target; - }; - gemObject* GetAttacker() + return attack; + } + + gemActor* GetAttacker() { return attacker; - }; - psCharacter* GetTargetData() + } + + gemActor* GetTarget() { - return targetdata; - }; - psCharacter* GetAttackerData() - { - return attackerdata; - }; + return target; + } + INVENTORY_SLOT_NUMBER GetWeaponSlot() { - return WeaponSlot; - }; + return weaponSlot; + } + psItem* GetWeapon() + { + return weapon; + } - int GetTargetID() + uint32_t GetTargetID() { return TargetCID; - }; - int GetAttackerID() + } + + uint32_t GetAttackerID() { return AttackerCID; - }; - int GetAttackResult() - { - return AttackResult; - }; + } + // These are just here to make it easy to pass data from Affect(). + MathEnvironment env; + INVENTORY_SLOT_NUMBER AttackLocation; ///< Which slot should we check the armor of? + float FinalDamage; ///< Final damage applied to target + +protected: + psAttack* attack; ///< The attack + csWeakRef<gemActor> attacker; ///< Entity who instigated this attack + csWeakRef<gemActor> target; ///< Entity who is target of this attack + uint32_t AttackerCID; ///< ClientID of attacker + uint32_t TargetCID; ///< ClientID of target + + INVENTORY_SLOT_NUMBER weaponSlot; ///< Identifier of the slot for which this attack event should process + // XXX There is some risk this pointer could point to trash + // if the item is deleted/stored. + psItem* weapon; ///< the attacking weapon }; + #endif Deleted: trunk/src/server/bulkobjects/psattackdefault.cpp =================================================================== --- trunk/src/server/bulkobjects/psattackdefault.cpp 2014-04-09 13:58:39 UTC (rev 9380) +++ trunk/src/server/bulkobjects/psattackdefault.cpp 2014-04-09 17:54:16 UTC (rev 9381) @@ -1,563 +0,0 @@ -/* - * psAttackDefault.cpp creator har...@gm... - * - * Copyright (C) 2001-2011 Atomic Blue (in...@pl..., http://www.atomicblue.org) - * - * - * 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 (version 2 of the License) - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - - -#include <psconfig.h> -#include "psattackdefault.h" -//============================================================================= -// Crystal Space Includes -//============================================================================= -#include <iutil/document.h> -#include <csutil/xmltiny.h> -#include <csgeom/math.h> - -//============================================================================= -// Project Includes -//============================================================================= -#include "util/log.h" -#include "util/mathscript.h" -#include "util/psdatabase.h" - -#include "psserver.h" -#include "gem.h" -#include "client.h" -#include "cachemanager.h" -#include "entitymanager.h" -#include "commandmanager.h" -#include "progressionmanager.h" -#include "combatmanager.h" -#include "npcmanager.h" -#include "../globals.h" -#include "scripting.h" -#include "netmanager.h" -#include "psserverchar.h" - -#include "engine/psworld.h" - -//============================================================================= -// Local Includes -//============================================================================= -#include "psquestprereqops.h" - -psAttackDefault::psAttackDefault() -{ -} - -psAttackDefault::~psAttackDefault() -{ -} - -bool psAttackDefault::IsDualWield(psCharacter* attacker) -{ - int count = 0; - //default being a dual wield depends on whether or not the character has 2 weapons or not, it is supposed to be flexible - for(int slot=0; slot<PSCHARACTER_SLOT_BULK1; slot++) - { - // See if this slot is able to attack - if(attacker->Inventory().CanItemAttack((INVENTORY_SLOT_NUMBER) slot)) - { - count++; - } - if(count > 1) //if it's greater than 1 it is a dualwield attack - break; - } - if(count > 1) - return true; - else - return false; -} - -bool psAttackDefault::Load(iResultRow &row) -{ - //no need to load anything for this particular attack - return true; -} - -bool psAttackDefault::CanAttack(Client* client) -{ - //default attack can always attack - return true; -} - -bool psAttackDefault::Attack(gemObject* attacker, gemObject* target,INVENTORY_SLOT_NUMBER slot) -{ - //queue up the attack - QueueAttack(attacker,slot,target,attacker->GetClientID(),target->GetClientID()); - return true; -} - -void psAttackDefault::QueueAttack(gemObject* attacker,INVENTORY_SLOT_NUMBER weaponslot,gemObject* target,int attackerCID, int targetCID) -{ - psCharacter* Character=attacker->GetCharacterData(); - psItem* Weapon=Character->Inventory().GetEffectiveWeaponInSlot(weaponslot); - float latency = Weapon->GetLatency(); - int delay = (int)(latency*1000); - - - psCombatAttackGameEvent* event; - event = new psCombatAttackGameEvent(delay,this,attacker,target,weaponslot,attackerCID,targetCID); - event->GetAttackerData()->TagEquipmentObject(weaponslot,event->id); - psserver->GetEventManager()->Push(event); -} - -void psAttackDefault::Affect(psCombatAttackGameEvent* event) -{ - - psCharacter* attacker_data; - int attack_result; - bool skipThisRound = false; - - if(!event->GetAttacker() || !event->GetTarget()) // disconnected and deleted - { - Debug2(LOG_COMBAT,0,"Attacker ID: %d. Combat stopped as one participant logged off.",event->AttackerCID); - return; - } - - // get attacker and target objects - gemActor* gemAttacker = dynamic_cast<gemActor*>((gemObject*) event->attacker); - gemActor* gemTarget = dynamic_cast<gemActor*>((gemObject*) event->target); - - attacker_data=event->GetAttackerData(); - - // If the attacker is no longer in attack mode abort. - if(gemAttacker->GetMode() != PSCHARACTER_MODE_COMBAT) - { - Debug2(LOG_COMBAT,0,"Combat stopped as attacker %d left combat mode.",event->AttackerCID); - return; - } - - // If target is dead, abort. - if(!gemTarget->IsAlive()) - { - Debug2(LOG_COMBAT,0,"Combat stopped as one participant logged off. Attacker ID: %d",event->AttackerCID); - return; - } - - // If the slot is no longer attackable, abort - if(!attacker_data->Inventory().CanItemAttack(event->GetWeaponSlot())) - { - Debug2(LOG_COMBAT,0,"Combat stopped as attacker has no longer an attacking item equipped. Attacker ID: %d",event->AttackerCID); - return; - } - - psItem* weapon = attacker_data->Inventory().GetEffectiveWeaponInSlot(event->GetWeaponSlot()); - - // weapon became unwieldable - csString response; - if(weapon!=NULL && !weapon->CheckRequirements(attacker_data,response)) - { - Debug2(LOG_COMBAT, gemAttacker->GetClientID(),"%s has lost use of weapon", gemAttacker->GetName()); - psserver->SendSystemError(event->AttackerCID, "You can't use your %s any more.", weapon->GetName()); - return; - } - - //If the weapon in the slot has been changed, skip a turn (latency for this slot may also have changed) - if(event->weapon->GetUID() != weapon->GetUID()) - { - Debug2(LOG_COMBAT, gemAttacker->GetClientID(),"Skipping attack because %s has changed weapons mid battle", gemAttacker->GetName()); - skipThisRound = true; - } - - Client* attacker_client = psserver->GetNetManager()->GetClient(event->AttackerCID); - - if(attacker_client) - { - // Input the stamina data - MathEnvironment env; - env.Define("Actor", event->GetAttacker()); - env.Define("Weapon", weapon); - - (void) psserver->GetCacheManager()->GetStaminaCombat()->Evaluate(&env); - - MathVar* PhyDrain = env.Lookup("PhyDrain"); - MathVar* MntDrain = env.Lookup("MntDrain"); - - // stop the attack if the attacker has no stamina left - if((attacker_client->GetCharacterData()->GetStamina(true) < PhyDrain->GetValue()) - || (attacker_client->GetCharacterData()->GetStamina(false) < MntDrain->GetValue())) - { - psserver->GetCombatManager()->StopAttack(attacker_data->GetActor()); - psserver->SendSystemError(event->AttackerCID, "You are too tired to attack."); - return; - } - - // If the target has become impervious, abort and give up attacking - csString msg; - if(!gemAttacker->IsAllowedToAttack(gemTarget,msg)) - { - psserver->GetCombatManager()->StopAttack(attacker_data->GetActor()); - return; - } - - //I will be seeing how this affects things and make changes accordingly - // If the target has changed, abort (assume another combat event has started since we are still in attack mode) - if(gemTarget != attacker_client->GetTargetObject()) - { - Debug2(LOG_COMBAT,0,"Skipping attack, Target changed for attacker ID: %d.",event->AttackerCID); - return; - } - } - else - { - // Check if the npc's target has changed (if it has, then assume another combat event has started.) - gemNPC* npcAttacker = dynamic_cast<gemNPC*>(gemAttacker); - if(npcAttacker && npcAttacker->GetTarget() != gemTarget) - { - Debug2(LOG_COMBAT,0,"Skipping attack, Target changed for attacker ID: %d.",event->AttackerCID); - return; - } - } - - if(gemAttacker->IsSpellCasting()) - { - psserver->SendSystemInfo(event->AttackerCID, "You can't attack while casting spells."); - skipThisRound = true; - } - - if(!skipThisRound) - { - if(weapon->GetIsRangeWeapon() && weapon->GetUsesAmmo()) - { - INVENTORY_SLOT_NUMBER otherHand = event->GetWeaponSlot() == PSCHARACTER_SLOT_RIGHTHAND ? - PSCHARACTER_SLOT_LEFTHAND: - PSCHARACTER_SLOT_RIGHTHAND; - - attack_result = ATTACK_NOTCALCULATED; - - psItem* otherItem = attacker_data->Inventory().GetInventoryItem(otherHand); - if(otherItem == NULL) - { - attack_result = ATTACK_OUTOFAMMO; - } - else if(otherItem->GetIsContainer()) // Is it a quiver? - { - // Pick the first ammo we can shoot from the container - // And set it as the active ammo - bool bFound = false; - for(size_t i=1; i<attacker_data->Inventory().GetInventoryIndexCount() && !bFound; i++) - { - psItem* currItem = attacker_data->Inventory().GetInventoryIndexItem(i); - if(currItem && - currItem->GetContainerID() == otherItem->GetUID() && - weapon->GetAmmoTypeID().In(currItem->GetBaseStats()->GetUID())) - { - otherItem = currItem; - bFound = true; - } - } - if(!bFound) - attack_result = ATTACK_OUTOFAMMO; - } - else if(!weapon->GetAmmoTypeID().In(otherItem->GetBaseStats()->GetUID())) - { - attack_result = ATTACK_OUTOFAMMO; - } - - if(attack_result != ATTACK_OUTOFAMMO) - { - psItem* usedAmmo = attacker_data->Inventory().RemoveItemID(otherItem->GetUID(), 1); - if(usedAmmo) - { - attack_result=CalculateAttack(event, usedAmmo); - usedAmmo->Destroy(); - psserver->GetCharManager()->UpdateItemViews(attacker_client->GetClientNum()); - } - else - attack_result=CalculateAttack(event); - } - - } - else - { - attack_result=CalculateAttack(event); - } - - event->AttackResult=attack_result; - AffectTarget(event,attack_result); - } -} - -int psAttackDefault::CalculateAttack(psCombatAttackGameEvent* event, psItem* subWeapon) -{ - INVENTORY_SLOT_NUMBER otherHand = event->GetWeaponSlot() == PSCHARACTER_SLOT_LEFTHAND ? PSCHARACTER_SLOT_RIGHTHAND : PSCHARACTER_SLOT_LEFTHAND; - event->AttackLocation = (INVENTORY_SLOT_NUMBER) psserver->GetCombatManager()->targetLocations[psserver->rng->Get((int) psserver->GetCombatManager()->targetLocations.GetSize())]; - - gemObject* attacker = event->GetAttacker(); - gemObject* target = event->GetTarget(); - - // calculate difference between target and attacker location - to be used for angle validation - csVector3 diff(0); // initialize to some big value that shows an error - - { - csVector3 attackPos, targetPos; - iSector* attackSector, *targetSector; - - attacker->GetPosition(attackPos, attackSector); - target->GetPosition(targetPos, targetSector); - - if((attacker->GetInstance() != target->GetInstance() && - attacker->GetInstance() != INSTANCE_ALL && target->GetInstance() != INSTANCE_ALL) || - !(psserver->GetCombatManager()->GetEntityManager()->GetWorld()->WarpSpace(targetSector, attackSector, targetPos))) - { - return ATTACK_OUTOFRANGE; - } - diff = targetPos - attackPos; - } - - MathEnvironment env; - env.Define("Attacker", attacker); - env.Define("Target", target); - env.Define("AttackWeapon", event->GetAttackerData()->Inventory().GetEffectiveWeaponInSlot(event->GetWeaponSlot())); - env.Define("AttackWeaponSecondary", subWeapon); - env.Define("TargetWeapon", event->GetTargetData()->Inventory().GetEffectiveWeaponInSlot(event->GetWeaponSlot(), true)); - env.Define("TargetWeaponSecondary", event->GetTargetData()->Inventory().GetEffectiveWeaponInSlot(otherHand,true)); - env.Define("AttackLocationItem", event->GetTargetData()->Inventory().GetEffectiveArmorInSlot(event->AttackLocation)); - env.Define("DiffX", diff.x ? diff.x : 0.00001F); // force minimal value - env.Define("DiffY", diff.y ? diff.y : 0.00001F); // force minimal value - env.Define("DiffZ", diff.z ? diff.z : 0.00001F); // force minimal value - - (void) psserver->GetCacheManager()->GetCalcDamage()->Evaluate(&env); - - if(DoLogDebug2(LOG_COMBAT, event->GetAttackerData()->GetPID().Unbox())) - { - CPrintf(CON_DEBUG, "Variables for Calculate Damage:\n"); - env.DumpAllVars(); - } - - MathVar* badrange = env.Lookup("BadRange"); // BadRange = Target is too far away - MathVar* badangle = env.Lookup("BadAngle"); // BadAngle = Attacker doesn't aim at enemy - MathVar* missed = env.Lookup("Missed"); // Missed = Attack missed the enemy - MathVar* dodged = env.Lookup("Dodged"); // Dodged = Attack dodged by enemy - MathVar* blocked = env.Lookup("Blocked"); // Blocked = Attack blocked by enemy - MathVar* damage = env.Lookup("FinalDamage"); // Actual damage done, if any - - if(badrange && badrange->GetValue() < 0.0) - return ATTACK_OUTOFRANGE; - else if(badangle && badangle->GetValue() < 0.0) - return ATTACK_BADANGLE; - else if(missed && missed->GetValue() < 0.0) - return ATTACK_MISSED; - else if(dodged && dodged->GetValue() < 0.0) - return ATTACK_DODGED; - else if(blocked && blocked->GetValue() < 0.0) - return ATTACK_BLOCKED; - - event->FinalDamage = damage->GetValue(); - - return ATTACK_DAMAGE; -} - -void psAttackDefault::AffectTarget(psCombatAttackGameEvent* event, int attack_result) -{ - psCharacter* attacker_data = event->GetAttackerData(); - psCharacter* target_data=event->GetTargetData(); - - MathVar* weaponDecay = NULL; - MathVar* blockDecay = NULL; - MathVar* armorDecay = NULL; - MathEnvironment env; - - psItem* weapon = attacker_data->Inventory().GetEffectiveWeaponInSlot(event->GetWeaponSlot()); - psItem* blockingWeapon = target_data->Inventory().GetEffectiveWeaponInSlot(event->GetWeaponSlot(),true); - psItem* struckArmor = target_data->Inventory().GetEffectiveArmorInSlot(event->AttackLocation); - - // there may only be a decay if you actually hit your target by some means - if(attack_result == ATTACK_DAMAGE || attack_result == ATTACK_BLOCKED) - { - // we are guaranteed some armor is present - real one, race one or base one - CS_ASSERT(struckArmor); - float ArmorVsWeapon = weapon->GetArmorVSWeaponResistance(struckArmor->GetBaseStats()); - - // clamp value between 0 and 1 - ArmorVsWeapon = ArmorVsWeapon > 1.0F ? 1.0F : ArmorVsWeapon < 0.0F ? 0.0F : ArmorVsWeapon; - - env.Define("Weapon", weapon); // weapon that was used to attack - env.Define("BlockingWeapon", blockingWeapon); // weapon that blocked the attack - env.Define("Armor", struckArmor); // armor hit - env.Define("ArmorVsWeapon", ArmorVsWeapon); // armor vs weapon effectiveness - env.Define("Damage", event->FinalDamage); // actual damage dealt - env.Define("Blocked", (attack_result == ATTACK_BLOCKED)); // identifies whether this attack was blocked - - (void) psserver->GetCacheManager()->GetCalcDecay()->Evaluate(&env); - - weaponDecay = env.Lookup("WeaponDecay"); - blockDecay = env.Lookup("BlockingDecay"); - armorDecay = env.Lookup("ArmorDecay"); - } - - gemActor* gemAttacker = dynamic_cast<gemActor*>((gemObject*) event->attacker); - gemActor* gemTarget = dynamic_cast<gemActor*>((gemObject*) event->target); - - switch(attack_result) - { - case ATTACK_DAMAGE: - { - bool isNearlyDead = false; - if(target_data->GetMaxHP().Current() > 0.0 && target_data->GetHP()/target_data->GetMaxHP().Current() > 0.2) - { - if((target_data->GetHP() - event->FinalDamage) / target_data->GetMaxHP().Current() <= 0.2) - isNearlyDead = true; - } - - psCombatEventMessage ev(event->AttackerCID, - isNearlyDead ? psCombatEventMessage::COMBAT_DAMAGE_NEARLY_DEAD : psCombatEventMessage::COMBAT_DAMAGE, - gemAttacker->GetEID(), - gemTarget->GetEID(), - event->AttackLocation, - event->FinalDamage, - weapon->GetAttackAnimID(gemAttacker->GetCharacterData()), - gemTarget->FindAnimIndex("hit")); - - ev.Multicast(gemTarget->GetMulticastClients(),0,MAX_COMBAT_EVENT_RANGE); - - // Apply final damage - if(target_data!=NULL) - { - gemTarget->DoDamage(gemAttacker,event->FinalDamage); - - if(gemAttacker) - { - gemAttacker->InvokeAttackScripts(gemTarget, weapon); - } - - if(gemTarget) - { - gemTarget->InvokeDefenseScripts(gemAttacker, weapon); - if(isNearlyDead) - { - gemTarget->InvokeNearlyDeadScripts(gemAttacker, weapon); - } - } - } - - // If the target wasn't in combat, it is now... - // Note that other modes shouldn't be interrupted automatically - if(gemTarget->GetMode() == PSCHARACTER_MODE_PEACE || gemTarget->GetMode() == PSCHARACTER_MODE_WORK) - { - if(gemTarget->GetClient()) // Set reciprocal target - { - gemTarget->GetClient()->SetTargetObject(gemAttacker,true); - gemTarget->SendTargetStatDR(gemTarget->GetClient()); - } - - // The default stance is 'Fully Defensive'. - Stance initialStance = psserver->GetCombatManager()->GetStance(psserver->GetCacheManager(), "FullyDefensive"); - psserver->GetCombatManager()->AttackSomeone(gemTarget,gemAttacker,initialStance); - } - - if(weapon) - { - weapon->AddDecay(weaponDecay->GetValue()); - } - if(struckArmor) - { - struckArmor->AddDecay(armorDecay->GetValue()); - } - - psserver->GetCombatManager()->NotifyTarget... [truncated message content] |
From: <jo...@us...> - 2014-04-17 04:41:14
|
Revision: 9452 http://sourceforge.net/p/planeshift/code/9452 Author: joelyon Date: 2014-04-17 04:41:11 +0000 (Thu, 17 Apr 2014) Log Message: ----------- Initial addition of spell timers to Active magic bar. More options and refinements to come. Modified Paths: -------------- trunk/src/client/gui/pawsactivemagicwindow.h trunk/src/client/gui/pawsdndbutton.cpp trunk/src/client/gui/pawsdndbutton.h trunk/src/client/gui/pawsscrollmenu.cpp trunk/src/client/gui/pawsscrollmenu.h trunk/src/client/gui/shortcutwindow.h trunk/src/common/net/messages.h trunk/src/server/gem.cpp Modified: trunk/src/client/gui/pawsactivemagicwindow.h =================================================================== --- trunk/src/client/gui/pawsactivemagicwindow.h 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/client/gui/pawsactivemagicwindow.h 2014-04-17 04:41:11 UTC (rev 9452) @@ -96,6 +96,7 @@ csRef<iVFS> vfs; bool useImages, + useTimers, autoResize, showEffects, show; ///<true==show spell & item effects; false==show spell effects but not item effects Modified: trunk/src/client/gui/pawsdndbutton.cpp =================================================================== --- trunk/src/client/gui/pawsdndbutton.cpp 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/client/gui/pawsdndbutton.cpp 2014-04-17 04:41:11 UTC (rev 9452) @@ -56,6 +56,7 @@ ImageNameCallback(NULL), NameCallback(NULL), ActionCallback(NULL), + spellProgress(NULL), backgroundBackup(""), DnDLock(false) { @@ -170,6 +171,71 @@ return true; } +void pawsDnDButton::Draw() +{ + + if(spellProgress!=NULL ) + { + csTicks currentTime = csGetTicks(); + float currentProgress = ((float)currentTime-(float)startTime)/(float)castingTime; + + fprintf( stderr, "pawsDnDButton::Draw %i, %i, %i, %i; startTime = %d, currentTime = %d, currentProgress= %f \n", GetScreenFrame().xmin, GetScreenFrame().ymin, GetScreenFrame().xmax-1, GetScreenFrame().ymax-1, startTime, currentTime, currentProgress); + + if (currentProgress >= 1.0) + { + //pawsButton::Draw(); + castingTime = 0; + spellProgress->Hide(); //this shouldn't be necessary as the server should be pushing out an updated spell list about this time. + pawsButton::Draw(); + + return; + } + spellProgress->SetCurrentValue(currentProgress); + spellProgress->DrawProgressBar( csRect(this->GetScreenFrame().xmin+3, this->GetScreenFrame().ymin+3, this->GetScreenFrame().xmax-3, this->GetScreenFrame().ymax-3), PawsManager::GetSingleton().GetGraphics3D(), currentProgress, + currentProgress>0.75?255:50, //red + currentProgress>0.75 && currentProgress<0.90?255:50, //green & yellow + currentProgress<0.75?255:50, //blue + 100, 100, 100 ); + + } + + pawsButton::Draw(); +} + +/** + * Start the timer on a button. primarily used for active magic bar. + * + * startTicks is the time the server recognized the spell cast begin + * currentTicks is the server's current time + * duration is how long the spell lasts + **/ +void pawsDnDButton::Start(csTicks startTicks, csTicks currentTicks, csTicks duration) +{ + Show(); + if( spellProgress!=NULL || duration==0 ) //if one already exists don't create a new one; if duration is 0 don't create one at all. + { + return; + } + + spellProgress=new pawsProgressBar(); + AddChild(spellProgress); + //BringToTop(spellProgress); + + spellProgress->SetTotalValue(1.0); + float currentProgress = (currentTicks-startTicks)/duration; + spellProgress->SetCurrentValue(currentProgress); + spellProgress->DrawProgressBar( csRect(this->GetScreenFrame().xmin+3, this->GetScreenFrame().ymin+3, this->GetScreenFrame().xmax-3, this->GetScreenFrame().ymax-3), PawsManager::GetSingleton().GetGraphics3D(), currentProgress, + currentProgress>0.75?255:50, //red + currentProgress>0.75 && currentProgress<0.90?255:50, //green & yellow + currentProgress<0.75?255:50, //blue + 100, 100, 100 ); + startTime = csGetTicks()-(currentTicks-startTicks);//note: this must be in terms of the client's ticks, not the server's + this->castingTime = duration; + +fprintf( stderr, "pawsDnDButton::Start( %d(client=%d), %d, %d )\n", startTicks, startTime, currentTicks, duration ); +} + + bool pawsDnDButton::SelfPopulate(iDocumentNode* node) { if(node->GetAttributeValue("text")) @@ -444,3 +510,8 @@ SetBackground(""); } } + +void pawsDnDButton::OnUpdateData(const char* /*dataname*/, PAWSData &value) +{ + spellProgress->SetCurrentValue(value.GetFloat()); +} Modified: trunk/src/client/gui/pawsdndbutton.h =================================================================== --- trunk/src/client/gui/pawsdndbutton.h 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/client/gui/pawsdndbutton.h 2014-04-17 04:41:11 UTC (rev 9452) @@ -25,6 +25,7 @@ #include "paws/pawswidget.h" #include "paws/pawsbutton.h" +#include "paws/pawsprogressbar.h" #include "psslotmgr.h" //#include "globals.h" @@ -39,7 +40,7 @@ * \addtogroup common_paws * @{ */ -/** A Drag-and-Drop capable button widget. +/** A Drag-and-Drop capable button widget with timer. */ class pawsDnDButton : public pawsButton { @@ -54,6 +55,9 @@ virtual bool OnMouseUp(int button, int modifiers, int x, int y); virtual void MouseOver(bool value); + virtual void Draw(); + void Start(csTicks startTicks, csTicks currentTicks, csTicks duration); + iPawsImage* GetMaskingImage(); void SetTextOffsetY( int offset ) @@ -195,6 +199,8 @@ } void EnableBackground( bool mode ); + + virtual void OnUpdateData(const char* /*dataname*/, PAWSData &value); protected: @@ -214,6 +220,8 @@ virtual bool CheckKeyHandled(int keyCode); bool DnDLock; // true = locked, false = enabled. + pawsProgressBar* spellProgress; + csTicks startTime,castingTime; }; //---------------------------------------------------------------------- Modified: trunk/src/client/gui/pawsscrollmenu.cpp =================================================================== --- trunk/src/client/gui/pawsscrollmenu.cpp 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/client/gui/pawsscrollmenu.cpp 2014-04-17 04:41:11 UTC (rev 9452) @@ -658,7 +658,7 @@ return true; } -bool pawsScrollMenu::LoadSingle(csString name, csString icon, csString toolTip, csString action, int Index, pawsWidget* widget, bool IsEnabled) +pawsDnDButton* pawsScrollMenu::LoadSingle(csString name, csString icon, csString toolTip, csString action, int Index, pawsWidget* widget, bool IsEnabled) { pawsDnDButton* button; button = new pawsDnDButton; @@ -697,7 +697,7 @@ { button->SetToolTip(toolTip); } - return true; + return button; } bool pawsScrollMenu::RemoveByName(csString name) Modified: trunk/src/client/gui/pawsscrollmenu.h =================================================================== --- trunk/src/client/gui/pawsscrollmenu.h 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/client/gui/pawsscrollmenu.h 2014-04-17 04:41:11 UTC (rev 9452) @@ -73,7 +73,7 @@ virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* reporter); bool LoadArrays(csArray<csString> &name, csArray<csString> &icon, csArray<csString> &toolTip, csArray<csString> &actions, int baseIndex, pawsWidget* widget); - bool LoadSingle(csString name, csString icon, csString toolTip, csString action, int Index, pawsWidget* widget, bool IsEnabled); + pawsDnDButton* LoadSingle(csString name, csString icon, csString toolTip, csString action, int Index, pawsWidget* widget, bool IsEnabled); bool RemoveByName(csString name); bool Clear(); Modified: trunk/src/client/gui/shortcutwindow.h =================================================================== --- trunk/src/client/gui/shortcutwindow.h 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/client/gui/shortcutwindow.h 2014-04-17 04:41:11 UTC (rev 9452) @@ -57,7 +57,7 @@ //============================================================================= /** - * + * The shortcut window itself */ class pawsShortcutWindow : public pawsControlledWindow, public pawsFingeringReceiver, public psClientNetSubscriber { @@ -177,6 +177,7 @@ pawsButton *UpButton; pawsButton *DownButton; pawsScrollBar *iconScrollBar; + pawsScrollBar *paletteScrollBar; csArray<csString> allIcons; csArray<csString> allNames; //not populated at this time... Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/common/net/messages.h 2014-04-17 04:41:11 UTC (rev 9452) @@ -3811,7 +3811,7 @@ enum commandType { Add, Remove, List }; - psGUIActiveMagicMessage(uint32_t clientNum, csArray<ActiveSpell*>& spells, uint32_t index ) + psGUIActiveMagicMessage(uint32_t clientNum, csArray<ActiveSpell*>& spells, uint32_t index, csTicks serverTime ) { // MSGTYPE_ACTIVEMAGIC + clientNum + command + valid + index + spellCount; size_t msgSize = sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t) + sizeof(bool) + sizeof(uint32_t) + sizeof(uint32_t); @@ -3822,6 +3822,8 @@ { msgSize += sizeof(uint8_t); //SPELL_TYPE msgSize += sizeof(uint32_t); //duration + msgSize += sizeof(uint32_t); //registrationTime + msgSize += sizeof(uint32_t); //serverTime msgSize += spells[i]->Name().Length() + 1; msgSize += spells[i]->Image().Length() + 1; } @@ -3836,6 +3838,8 @@ { msg->Add((uint8_t)spells[i]->Type()); msg->Add((uint32_t)spells[i]->Duration()); + msg->Add((uint32_t)spells[i]->RegistrationTime()); + msg->Add((uint32_t)serverTime); msg->Add(spells[i]->Name().GetData()); msg->Add(spells[i]->Image().GetData()); } @@ -3864,6 +3868,8 @@ { type.Push( (SPELL_TYPE) message->GetUInt8() ); duration.Push( message->GetUInt32()); + registrationTime.Push( message->GetUInt32()); + serverTime=message->GetUInt32(); name.Push( message->GetStr()); //if there was no name when the message was sent, this should read a null string image.Push( message->GetStr()); //if there was no name when the message was sent, this should read a null string } @@ -3884,6 +3890,8 @@ commandType command; csArray<SPELL_TYPE> type; csArray<uint32> duration; + csArray<uint32> registrationTime; + uint32 serverTime; csArray<csString> name; csArray<csString> image; }; Modified: trunk/src/server/gem.cpp =================================================================== --- trunk/src/server/gem.cpp 2014-04-17 00:26:02 UTC (rev 9451) +++ trunk/src/server/gem.cpp 2014-04-17 04:41:11 UTC (rev 9452) @@ -4458,7 +4458,7 @@ void gemActor::SendActiveSpells() { - psGUIActiveMagicMessage outgoing(GetClientID(), activeSpells, GetActiveMagicSequence()); // <---add message index tracking! + psGUIActiveMagicMessage outgoing(GetClientID(), activeSpells, GetActiveMagicSequence(), csGetTicks()); // <---add message index tracking! outgoing.SendMessage(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2014-05-10 21:35:32
|
Revision: 9506 http://sourceforge.net/p/planeshift/code/9506 Author: joelyon Date: 2014-05-10 21:35:29 +0000 (Sat, 10 May 2014) Log Message: ----------- Fix the erroneous clipping on masking images. Modified Paths: -------------- trunk/src/client/gui/pawsdndbutton.cpp trunk/src/client/gui/pawsscrollmenu.cpp trunk/src/common/paws/pawswidget.cpp Modified: trunk/src/client/gui/pawsdndbutton.cpp =================================================================== --- trunk/src/client/gui/pawsdndbutton.cpp 2014-05-10 18:13:04 UTC (rev 9505) +++ trunk/src/client/gui/pawsdndbutton.cpp 2014-05-10 21:35:29 UTC (rev 9506) @@ -474,6 +474,7 @@ { } + void pawsDnDButton::DrawMask() { // Draw the masking image @@ -491,7 +492,7 @@ imageX = screenFrame.xmin+(screenFrame.Width()/2)-(screenFrame.Height()/2); - graphics2D->SetClipRect( 0,0, graphics2D->GetWidth(), graphics2D->GetHeight()); + ClipToParent(true); maskImage->Draw(imageX, screenFrame.ymin, screenFrame.Height(), screenFrame.Height(), drawAlpha); } } Modified: trunk/src/client/gui/pawsscrollmenu.cpp =================================================================== --- trunk/src/client/gui/pawsscrollmenu.cpp 2014-05-10 18:13:04 UTC (rev 9505) +++ trunk/src/client/gui/pawsscrollmenu.cpp 2014-05-10 21:35:29 UTC (rev 9506) @@ -330,7 +330,7 @@ } else if(Buttons[i]->GetScreenFrame().xmax <= ButtonHolder->GetScreenFrame().xmin || Buttons[i]->GetScreenFrame().xmax > ButtonHolder->GetScreenFrame().xmax || Buttons[i]->GetScreenFrame().ymax >= ButtonHolder->GetScreenFrame().ymax) { - Buttons[i]->Hide(); + //Buttons[i]->Hide(); } else { Modified: trunk/src/common/paws/pawswidget.cpp =================================================================== --- trunk/src/common/paws/pawswidget.cpp 2014-05-10 18:13:04 UTC (rev 9505) +++ trunk/src/common/paws/pawswidget.cpp 2014-05-10 21:35:29 UTC (rev 9506) @@ -1232,8 +1232,8 @@ } if(maskImage) { - graphics2D->SetClipRect(0,0, graphics2D->GetWidth(), graphics2D->GetHeight()); - maskImage->Draw(screenFrame.xmin, screenFrame.ymin, screenFrame.Width(), screenFrame.Height(), drawAlpha); + ClipToParent(true); + maskImage->Draw(screenFrame, drawAlpha); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2014-06-29 15:03:28
|
Revision: 9520 http://sourceforge.net/p/planeshift/code/9520 Author: joelyon Date: 2014-06-29 15:03:24 +0000 (Sun, 29 Jun 2014) Log Message: ----------- -Add color thresholds "warn" and "danger", and flash threshold to pawsProgressBar -refactor pawsDnDButton to use now-builtin threshold settings for timer in pawsProgressBar Modified Paths: -------------- trunk/src/client/gui/pawsdndbutton.cpp trunk/src/client/gui/pawsdndbutton.h trunk/src/common/paws/pawsprogressbar.cpp trunk/src/common/paws/pawsprogressbar.h Modified: trunk/src/client/gui/pawsdndbutton.cpp =================================================================== --- trunk/src/client/gui/pawsdndbutton.cpp 2014-06-27 20:07:34 UTC (rev 9519) +++ trunk/src/client/gui/pawsdndbutton.cpp 2014-06-29 15:03:24 UTC (rev 9520) @@ -35,6 +35,7 @@ #include "paws/pawsmanager.h" #include "paws/pawsbutton.h" #include "gui/pawsdndbutton.h" +#include "gui/pawsscrollmenu.h" #include "paws/pawstexturemanager.h" #include "paws/pawsprefmanager.h" @@ -56,7 +57,8 @@ NameCallback(NULL), ActionCallback(NULL), DnDLock(false), - spellProgress(NULL) + spellProgress(NULL), + action(NULL) { factory = "pawsDnDButton"; } @@ -171,7 +173,6 @@ void pawsDnDButton::Draw() { - if(spellProgress!=NULL ) { csTicks currentTime = csGetTicks(); @@ -183,17 +184,13 @@ { //pawsButton::Draw(); castingTime = 0; - spellProgress->Hide(); //this shouldn't be necessary as the server should be pushing out an updated spell list about this time. + spellProgress->Hide(); //this *shouldn't* be necessary as the server should be pushing out an updated spell list about this time, but we include this in case of missed packets. pawsButton::Draw(); return; } spellProgress->SetCurrentValue(currentProgress); - spellProgress->DrawProgressBar( csRect(this->GetScreenFrame().xmin+3, this->GetScreenFrame().ymin+3, this->GetScreenFrame().xmax-3, this->GetScreenFrame().ymax-3), PawsManager::GetSingleton().GetGraphics3D(), currentProgress, - currentProgress>0.75?255:50, //red - currentProgress>0.75 && currentProgress<0.90?255:50, //green & yellow - currentProgress<0.75?255:50, //blue - 100, 100, 100 ); + spellProgress->SetRelativeFrame( 3, 3, screenFrame.Width()-6, screenFrame.Height()-6 ); csString TipWithTiming = baseToolTip; TipWithTiming.Append( ", " ); @@ -214,7 +211,6 @@ **/ void pawsDnDButton::Start(csTicks startTicks, csTicks currentTicks, csTicks duration) { - Show(); if( spellProgress!=NULL || duration==0 ) //if one already exists don't create a new one; if duration is 0 don't create one at all. { return; @@ -224,13 +220,13 @@ AddChild(spellProgress); spellProgress->SetTotalValue(1.0); + spellProgress->SetColor( 0, 0, 200 ); + spellProgress->SetWarning(0.5, false, 200, 200, 0 ); + spellProgress->SetDanger(0.8, false, 200, 0, 0 ); + spellProgress->SetFlash(0.75, false, 250, 0, 0, 0 ); + float currentProgress = (currentTicks-startTicks)/duration; spellProgress->SetCurrentValue(currentProgress); - spellProgress->DrawProgressBar( csRect(this->GetScreenFrame().xmin+3, this->GetScreenFrame().ymin+3, this->GetScreenFrame().xmax-3, this->GetScreenFrame().ymax-3), PawsManager::GetSingleton().GetGraphics3D(), currentProgress, - currentProgress>0.75?255:50, //red - currentProgress>0.75 && currentProgress<0.90?255:50, //green & yellow - currentProgress<0.75?255:50, //blue - 100, 100, 100 ); startTime = csGetTicks()-(currentTicks-startTicks);//note: this must be in terms of the client's ticks, not the server's this->castingTime = duration; } @@ -523,3 +519,12 @@ baseToolTip = toolTip; pawsButton::SetToolTip( toolTip ); } + +void pawsDnDButton::SetRelativeFrame(int x, int y, int width, int height) +{ + if( spellProgress ) + { + spellProgress->SetRelativeFrame(x, y, width, height); + } + pawsWidget::SetRelativeFrame(x, y, width, height); +} Modified: trunk/src/client/gui/pawsdndbutton.h =================================================================== --- trunk/src/client/gui/pawsdndbutton.h 2014-06-27 20:07:34 UTC (rev 9519) +++ trunk/src/client/gui/pawsdndbutton.h 2014-06-29 15:03:24 UTC (rev 9520) @@ -103,13 +103,13 @@ } const char* GetName() { - if(NameCallback) - { - if(NameCallback->Get(id-indexBase).Length()>0) - { - return NameCallback->Get(id-indexBase).GetData(); - } - } + //if(NameCallback) + //{ + // if(NameCallback->Get(id-indexBase).Length()>0) + // { + // return NameCallback->Get(id-indexBase).GetData(); + // } + //} if(GetText()) return GetText(); return NULL; @@ -141,9 +141,18 @@ } void SetAction(const char* act) { - SetAction(csString(act)); + if( act!=NULL ) + { + action=new csString( act ); +fprintf( stderr, "PawsDnDButton::SetAction sees action as '%s'\n", action->GetData() ); + } + else + { + action=NULL; + } + //SetAction(new csString(act)); } - void SetAction(csString act) + void SetAction(csString* act) { if(ActionCallback) { @@ -153,15 +162,30 @@ } const char* GetAction() { - if(action) +fprintf( stderr, "PawsDnDButton::GetAction begins\n" ); + if(action!=NULL) { - if(!action.IsEmpty()) +fprintf( stderr, "PawsDnDButton::GetAction sees action as non NULL\n" ); + if(!action->IsEmpty()) { - return action.GetData(); +fprintf( stderr, "PawsDnDButton::GetAction sees action as '%s'\n", action->GetData() ); + return action->GetData(); } } +fprintf( stderr, "PawsDnDButton::GetAction sees action as NULL\n" ); return NULL; } + const char* GetTooltip() + { + if(baseToolTip) + { + if(!baseToolTip.IsEmpty()) + { + return baseToolTip.GetData(); + } + } + return NULL; + } void SetDnDLock(bool locked) { @@ -204,11 +228,13 @@ void SetToolTip( const char * tooltip ); + virtual void SetRelativeFrame(int x, int y, int width, int height); + protected: psSlotManager* mgr; int dragDrop; int dragDropInProgress; - csString action; + csString* action; int containerID; int indexBase; int editMode; Modified: trunk/src/common/paws/pawsprogressbar.cpp =================================================================== --- trunk/src/common/paws/pawsprogressbar.cpp 2014-06-27 20:07:34 UTC (rev 9519) +++ trunk/src/common/paws/pawsprogressbar.cpp 2014-06-29 15:03:24 UTC (rev 9520) @@ -30,13 +30,24 @@ percent = 0.0f; factory = "pawsProgressBar"; warnLevel = -1; + warnLow = true; dangerLevel = -1; + dangerLow = true; flashLevel = -1; - flashLastTime = -1; + flashLastTime= -1; flashLow = true; flashRate = 0; On = true; reversed = false; + + start_r=start_g=start_b=255; + flash_r=flash_g=flash_b=0; + warn_r=warn_g=200; + warn_b=0; + danger_r=200; + danger_g=danger_b=0; + diff_r=diff_g=diff_b=100; + } pawsProgressBar::pawsProgressBar(const pawsProgressBar &origin) :pawsWidget(origin), @@ -76,12 +87,6 @@ diff_g = ColourNode2->GetAttributeValueAsInt("g") - start_g; diff_b = ColourNode2->GetAttributeValueAsInt("b") - start_b; } - else - { - diff_r = 0; - diff_g = 0; - diff_b = 0; - } csRef<iDocumentNode> ColourNode3 = node->GetNode("flashcolor"); if(ColourNode3) @@ -96,6 +101,34 @@ flash_g = 0; flash_b = 0; } + + csRef<iDocumentNode> ColourNode4 = node->GetNode("warncolor"); + if(ColourNode4) + { + warn_r = ColourNode4->GetAttributeValueAsInt("r"); + warn_g = ColourNode4->GetAttributeValueAsInt("g"); + warn_b = ColourNode4->GetAttributeValueAsInt("b"); + } + else + { + warn_r = 200; + warn_g = 200; + warn_b = 0; + } + + csRef<iDocumentNode> ColourNode5 = node->GetNode("dangercolor"); + if(ColourNode5) + { + danger_r = ColourNode5->GetAttributeValueAsInt("r"); + danger_g = ColourNode5->GetAttributeValueAsInt("g"); + danger_b = ColourNode5->GetAttributeValueAsInt("b"); + } + else + { + danger_r = 200; + danger_g = 0; + danger_b = 0; + } return true; } @@ -136,9 +169,9 @@ On=true; } } - if( warnLevel > 0 && percent < warnLevel ) + if( warnLevel > 0 && ( (warnLow && percent < warnLevel) || (!warnLow && percent >warnLevel) ) ) { - if( dangerLevel > 0 && percent < dangerLevel ) + if( dangerLevel > 0 && ( (dangerLow && percent < dangerLevel) || (!dangerLow && percent >dangerLevel) ) ) { primary_r = danger_r; primary_g = danger_g; @@ -157,18 +190,17 @@ primary_g = start_g; primary_b = start_b; } - if( On ) { DrawProgressBar(screenFrame, PawsManager::GetSingleton().GetGraphics3D(), percent, - primary_r, primary_g, primary_b, - diff_r, diff_g, diff_b, alpha); + primary_r, primary_g, primary_b, + diff_r, diff_g, diff_b, alpha); } else { DrawProgressBar(screenFrame, PawsManager::GetSingleton().GetGraphics3D(), percent, - flash_r, flash_g, flash_b, - diff_r, diff_g, diff_b, alpha); + flash_r, flash_g, flash_b, + flash_r, flash_g, flash_b, alpha); } DrawChildren(); DrawMask(); @@ -221,11 +253,21 @@ SetCurrentValue(value.GetFloat()); } -void pawsProgressBar::SetFlash(float level, bool low, int rate ) +void pawsProgressBar::SetColor( int red, int green, int blue ) { + start_r = red; + start_g = green; + start_b = blue; +} + +void pawsProgressBar::SetFlash(float level, bool low, int rate, int red, int green, int blue ) +{ flashLevel = level; flashLow = low; flashRate = rate; + flash_r = red; + flash_g = green; + flash_b = blue; } void pawsProgressBar::SetReversed( bool val ) @@ -233,17 +275,19 @@ reversed = val; } -void pawsProgressBar::SetWarning( float level, int red, int green, int blue ) +void pawsProgressBar::SetWarning( float level, bool low, int red, int green, int blue ) { warnLevel = level; + warnLow = low; warn_r = red; warn_g = green; warn_b = blue; } -void pawsProgressBar::SetDanger( float level, int red, int green, int blue ) +void pawsProgressBar::SetDanger( float level, bool low, int red, int green, int blue ) { dangerLevel = level; + dangerLow = low; danger_r = red; danger_g = green; danger_b = blue; Modified: trunk/src/common/paws/pawsprogressbar.h =================================================================== --- trunk/src/common/paws/pawsprogressbar.h 2014-06-27 20:07:34 UTC (rev 9519) +++ trunk/src/common/paws/pawsprogressbar.h 2014-06-29 15:03:24 UTC (rev 9520) @@ -41,30 +41,42 @@ totalValue = newValue; } + /** set the base color + * @param red red saturation value + * @param green green saturation value + * @param blue blue saturation value + */ + virtual void SetColor( int red, int green, int blue ); + /** flash a different color if value is below/above threshold. ** numbers outside of min & max = no flash. ** default = no flash. - * @param value within this threshold, flash; outside it, no flash. - * @param low if TRUE then flash below this level; if FALSE flash above. - * @param rate switch colors every 'rate' ticks + * @param value within this threshold, flash; outside it, no flash. + * @param low if TRUE then flash below this level; if FALSE flash above. + * @param rate switch colors every 'rate' ticks + * @param red red saturation value + * @param green green saturation value + * @param blue blue saturation value */ - virtual void SetFlash(float level, bool low, int rate ); + virtual void SetFlash(float level, bool low, int rate, int red, int green, int blue ); /** use a different primary color if above a certain threshold * @param level threshold + * @param low if TRUE then active below this level; if FALSE active above. * @param red red saturation value - * @param green green saturation value - * @param blue blue saturation value + * @param green green saturation value + * @param blue blue saturation value */ - virtual void SetWarning( float level, int red, int green, int blue ); + virtual void SetWarning( float level, bool low, int red, int green, int blue ); /** use a different primary color if above a certain threshold * @param level threshold + * @param low if TRUE then active below this level; if FALSE active above. * @param red red saturation value - * @param green green saturation value - * @param blue blue saturation value + * @param green green saturation value + * @param blue blue saturation value */ - virtual void SetDanger( float level, int red, int green, int blue ); + virtual void SetDanger( float level, bool low, int red, int green, int blue ); void Completed() { @@ -106,6 +118,8 @@ int flashLastTime; bool complete; bool flashLow; //Low = TRUE; High = FALSE + bool warnLow; //Low = TRUE; High = FALSE + bool dangerLow; //Low = TRUE; High = FALSE bool On; //Primary color showing = TRUE; flash color = FALSE; bool reversed; //FALSE = left-to-right (default); TRUE = right-to-left (reversed) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2014-08-02 21:58:52
|
Revision: 9534 http://sourceforge.net/p/planeshift/code/9534 Author: joelyon Date: 2014-08-02 21:58:47 +0000 (Sat, 02 Aug 2014) Log Message: ----------- Added config interface for warn, danger and flash levels on Shortcut menu's Health and Mana bars. Modified Paths: -------------- trunk/src/client/gui/pawsconfigshortcut.cpp trunk/src/client/gui/pawsconfigshortcut.h trunk/src/client/gui/shortcutwindow.cpp trunk/src/client/gui/shortcutwindow.h trunk/src/common/paws/pawsprogressbar.cpp trunk/src/common/paws/pawsprogressbar.h Modified: trunk/src/client/gui/pawsconfigshortcut.cpp =================================================================== --- trunk/src/client/gui/pawsconfigshortcut.cpp 2014-08-01 22:47:11 UTC (rev 9533) +++ trunk/src/client/gui/pawsconfigshortcut.cpp 2014-08-02 21:58:47 UTC (rev 9534) @@ -56,6 +56,12 @@ textSize(NULL), textSpacing(NULL), ShortcutMenu(NULL), + HPWarnLevel(NULL), + HPDangerLevel(NULL), + HPFlashLevel(NULL), + ManaWarnLevel(NULL), + ManaDangerLevel(NULL), + ManaFlashLevel(NULL), MenuBar(NULL) { loaded= false; @@ -193,6 +199,66 @@ textSpacing->SetMaxValue(20); + HPWarnLevel = (pawsScrollBar*)FindWidget("HPWarnLevel"); + if(!HPWarnLevel) + { + return false; + } + HPWarnLevel->EnableValueLimit(true); + HPWarnLevel->SetMinValue(0); + HPWarnLevel->SetMaxValue(100); + HPWarnLevel->SetCurrentValue(0,false); + + HPDangerLevel = (pawsScrollBar*)FindWidget("HPDangerLevel"); + if(!HPDangerLevel) + { + return false; + } + HPDangerLevel->EnableValueLimit(true); + HPDangerLevel->SetMinValue(0); + HPDangerLevel->SetMaxValue(100); + HPDangerLevel->SetCurrentValue(0,false); + + HPFlashLevel = (pawsScrollBar*)FindWidget("HPFlashLevel"); + if(!HPFlashLevel) + { + return false; + } + HPFlashLevel->EnableValueLimit(true); + HPFlashLevel->SetMinValue(0); + HPFlashLevel->SetMaxValue(100); + HPFlashLevel->SetCurrentValue(0,false); + + ManaWarnLevel = (pawsScrollBar*)FindWidget("ManaWarnLevel"); + if(!ManaWarnLevel) + { + return false; + } + ManaWarnLevel->EnableValueLimit(true); + ManaWarnLevel->SetMinValue(0); + ManaWarnLevel->SetMaxValue(100); + ManaWarnLevel->SetCurrentValue(0,false); + + ManaDangerLevel = (pawsScrollBar*)FindWidget("ManaDangerLevel"); + if(!ManaDangerLevel) + { + return false; + } + ManaDangerLevel->EnableValueLimit(true); + ManaDangerLevel->SetMinValue(0); + ManaDangerLevel->SetMaxValue(100); + ManaDangerLevel->SetCurrentValue(0,false); + + ManaFlashLevel = (pawsScrollBar*)FindWidget("ManaFlashLevel"); + if(!ManaFlashLevel) + { + return false; + } + ManaFlashLevel->EnableValueLimit(true); + ManaFlashLevel->SetMinValue(0); + ManaFlashLevel->SetMaxValue(100); + ManaFlashLevel->SetCurrentValue(0,false); + return true; } @@ -278,6 +344,12 @@ } healthAndMana->SetState( ((pawsShortcutWindow*)ShortcutMenu)->GetMonitorState() ); + HPWarnLevel->SetCurrentValue( ((pawsShortcutWindow*)ShortcutMenu)->GetHPWarnLevel() ); + HPDangerLevel->SetCurrentValue( ((pawsShortcutWindow*)ShortcutMenu)->GetHPDangerLevel() ); + HPFlashLevel->SetCurrentValue( ((pawsShortcutWindow*)ShortcutMenu)->GetHPFlashLevel() ); + ManaWarnLevel->SetCurrentValue( ((pawsShortcutWindow*)ShortcutMenu)->GetManaWarnLevel() ); + ManaDangerLevel->SetCurrentValue( ((pawsShortcutWindow*)ShortcutMenu)->GetManaDangerLevel() ); + ManaFlashLevel->SetCurrentValue( ((pawsShortcutWindow*)ShortcutMenu)->GetManaFlashLevel() ); enableScrollBar->TurnAllOff(); @@ -314,8 +386,22 @@ editLockMode->GetActive().GetData()); xml.AppendFmt("<enableScrollBar active=\"%s\" />\n", enableScrollBar->GetActive().GetData()); + xml.AppendFmt("<healthAndMana on=\"%s\" />\n", healthAndMana->GetState() ? "yes" : "no"); + xml.AppendFmt("<HPWarnLevel value=\"%d\" />\n", + int(HPWarnLevel->GetCurrentValue())); + xml.AppendFmt("<HPDangerLevel value=\"%d\" />\n", + int(HPDangerLevel->GetCurrentValue())); + xml.AppendFmt("<HPFlashLevel value=\"%d\" />\n", + int(HPFlashLevel->GetCurrentValue())); + xml.AppendFmt("<ManaWarnLevel value=\"%d\" />\n", + int(ManaWarnLevel->GetCurrentValue())); + xml.AppendFmt("<ManaDangerLevel value=\"%d\" />\n", + int(ManaDangerLevel->GetCurrentValue())); + xml.AppendFmt("<ManaFlashLevel value=\"%d\" />\n", + int(ManaFlashLevel->GetCurrentValue())); + xml.AppendFmt("<buttonBackground on=\"%s\" />\n", buttonBackground->GetState() ? "yes" : "no"); xml.AppendFmt("<textSize value=\"%d\" />\n", @@ -373,6 +459,64 @@ MenuBar->SetButtonPaddingWidth( textSpacing->GetCurrentValue() ); MenuBar->LayoutButtons(); } + else if(wdg == HPWarnLevel ) + { + if( HPWarnLevel->GetCurrentValue()>0 ) + { + if( HPWarnLevel->GetCurrentValue()<HPDangerLevel->GetCurrentValue() ) + { + HPDangerLevel->SetCurrentValue( HPWarnLevel->GetCurrentValue() ); + } + ((pawsShortcutWindow*)(ShortcutMenu))->SetHPWarnLevel( HPWarnLevel->GetCurrentValue()/100 ); + } + } + else if(wdg == HPDangerLevel ) + { + if( HPDangerLevel->GetCurrentValue()>0 ) + { + if( HPDangerLevel->GetCurrentValue()>HPWarnLevel->GetCurrentValue() ) + { + HPDangerLevel->SetCurrentValue( HPWarnLevel->GetCurrentValue() ); + } + ((pawsShortcutWindow*)(ShortcutMenu))->SetHPDangerLevel( HPDangerLevel->GetCurrentValue()/100 ); + } + } + else if(wdg == HPFlashLevel ) + { + if( HPFlashLevel->GetCurrentValue()>0 ) + { + ((pawsShortcutWindow*)(ShortcutMenu))->SetHPFlashLevel( HPFlashLevel->GetCurrentValue()/100 ); + } + } + else if(wdg == ManaWarnLevel ) + { + if( ManaWarnLevel->GetCurrentValue()>0 ) + { + if( ManaWarnLevel->GetCurrentValue()<ManaDangerLevel->GetCurrentValue() ) + { + ManaDangerLevel->SetCurrentValue( ManaWarnLevel->GetCurrentValue() ); + } + ((pawsShortcutWindow*)(ShortcutMenu))->SetManaWarnLevel( ManaWarnLevel->GetCurrentValue()/100 ); + } + } + else if(wdg == ManaDangerLevel ) + { + if( ManaDangerLevel->GetCurrentValue()>0 ) + { + if( ManaDangerLevel->GetCurrentValue()>ManaWarnLevel->GetCurrentValue() ) + { + ManaDangerLevel->SetCurrentValue( ManaWarnLevel->GetCurrentValue() ); + } + ((pawsShortcutWindow*)(ShortcutMenu))->SetManaDangerLevel( ManaDangerLevel->GetCurrentValue()/100 ); + } + } + else if(wdg == ManaFlashLevel ) + { + if( ManaFlashLevel->GetCurrentValue()>0 ) + { + ((pawsShortcutWindow*)(ShortcutMenu))->SetManaFlashLevel( ManaFlashLevel->GetCurrentValue()/100 ); + } + } if( loaded ) SaveConfig(); Modified: trunk/src/client/gui/pawsconfigshortcut.h =================================================================== --- trunk/src/client/gui/pawsconfigshortcut.h 2014-08-01 22:47:11 UTC (rev 9533) +++ trunk/src/client/gui/pawsconfigshortcut.h 2014-08-02 21:58:47 UTC (rev 9534) @@ -90,6 +90,13 @@ pawsWidget* ShortcutMenu; pawsScrollMenu* MenuBar; + pawsScrollBar* HPWarnLevel; + pawsScrollBar* HPDangerLevel; + pawsScrollBar* HPFlashLevel; + pawsScrollBar* ManaWarnLevel; + pawsScrollBar* ManaDangerLevel; + pawsScrollBar* ManaFlashLevel; + bool loaded; }; Modified: trunk/src/client/gui/shortcutwindow.cpp =================================================================== --- trunk/src/client/gui/shortcutwindow.cpp 2014-08-01 22:47:11 UTC (rev 9533) +++ trunk/src/client/gui/shortcutwindow.cpp 2014-08-02 21:58:47 UTC (rev 9534) @@ -296,18 +296,8 @@ MenuBar->SetButtonWidth( buttonWidth ); MenuBar->SetEditMode( EditMode ); - //if( scrollSize>1 ) - //{ - // MenuBar->SetScrollIncrement( (int)scrollSize ); - //} - //else - //{ - // MenuBar->SetScrollProportion( scrollSize ); - //} - MenuBar->SetButtonPaddingWidth( textSpacing ); - n = names; for( i=0; i<names.GetSize(); i++ ) { @@ -428,7 +418,6 @@ while(Iter.HasNext()) { csString curr = csString(Iter.Next()->GetName()); -//fprintf(stderr, "pawsShortcutWindow::OnButtonReleased building icon palette, item %s\n", curr.GetData() ); size_t i; if( allIcons.IsEmpty() ) { @@ -437,10 +426,8 @@ } for( i=0; i<allIcons.GetSize(); i++) //insertion sort { -//fprintf(stderr, "......comparing to item %i - %s\n", i, allIcons[i].GetData() ); if( allIcons[i] > curr ) { -//fprintf(stderr, "......inserting\n" ); allIcons.Insert(i, curr.GetData()); break; } @@ -1155,7 +1142,69 @@ { Error1("pawsShortcutWindow::LoadUserPrefs unable to retrieve healthAndMana node"); } + optionNode = mainNode->GetNode("HPWarnLevel"); + if(optionNode != NULL) + { + SetHPWarnLevel(optionNode->GetAttributeValueAsFloat("value", true)/100); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve warnLevel node"); + SetHPWarnLevel(0); + } + optionNode = mainNode->GetNode("HPDangerLevel"); + if(optionNode != NULL) + { + SetHPDangerLevel(optionNode->GetAttributeValueAsFloat("value", true)/100); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve warnLevel node"); + SetHPDangerLevel(0); + } + optionNode = mainNode->GetNode("HPFlashLevel"); + if(optionNode != NULL) + { + SetHPFlashLevel(optionNode->GetAttributeValueAsFloat("value", true)/100); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve warnLevel node"); + SetHPFlashLevel(0); + } + optionNode = mainNode->GetNode("ManaWarnLevel"); + if(optionNode != NULL) + { + SetManaWarnLevel(optionNode->GetAttributeValueAsFloat("value", true)/100); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve warnLevel node"); + SetManaWarnLevel(0); + } + optionNode = mainNode->GetNode("ManaDangerLevel"); + if(optionNode != NULL) + { + SetManaDangerLevel(optionNode->GetAttributeValueAsFloat("value", true)/100); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve warnLevel node"); + SetManaDangerLevel(0); + } + optionNode = mainNode->GetNode("ManaFlashLevel"); + if(optionNode != NULL) + { + SetManaFlashLevel(optionNode->GetAttributeValueAsFloat("value", true)/100); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve warnLevel node"); + SetManaFlashLevel(0); + } + + optionNode = mainNode->GetNode("buttonBackground"); if(optionNode != NULL) { @@ -1206,3 +1255,99 @@ return true; } + +void pawsShortcutWindow::SetHPWarnLevel( float val ) +{ + if( main_hp ) + { + main_hp->SetWarning(val,true,200,200,0); + } +} +float pawsShortcutWindow::GetHPWarnLevel() +{ + if( main_hp ) + { + return main_hp->GetWarningLevel(); + } + return 0; +} + +void pawsShortcutWindow::SetHPDangerLevel( float val ) +{ + if( main_hp ) + { + main_hp->SetDanger(val,true,250,0,0); + } +} +float pawsShortcutWindow::GetHPDangerLevel() +{ + if( main_hp ) + { + return main_hp->GetDangerLevel(); + } + return 0; +} + +void pawsShortcutWindow::SetHPFlashLevel( float val ) +{ + if( main_hp ) + { + main_hp->SetFlash(val,true,200,0,0,0); + } +} +float pawsShortcutWindow::GetHPFlashLevel() +{ + if( main_hp ) + { + return main_hp->GetFlashLevel(); + } + return 0; +} + +void pawsShortcutWindow::SetManaWarnLevel( float val ) +{ + if( main_mana ) + { + main_mana->SetWarning(val,true,200,200,200); + } +} +float pawsShortcutWindow::GetManaWarnLevel() +{ + if( main_mana ) + { + return main_mana->GetWarningLevel(); + } + return 0; +} + +void pawsShortcutWindow::SetManaDangerLevel( float val ) +{ + if( main_mana ) + { + main_mana->SetDanger(val,true,250,0,0); + } +} +float pawsShortcutWindow::GetManaDangerLevel() +{ + if( main_mana ) + { + return main_mana->GetDangerLevel(); + } + return 0; +} + +void pawsShortcutWindow::SetManaFlashLevel( float val ) +{ + if( main_mana ) + { + main_mana->SetFlash(val,true,200,0,0,0); + } +} +float pawsShortcutWindow::GetManaFlashLevel() +{ + if( main_mana ) + { + return main_mana->GetFlashLevel(); + } + return 0; +} Modified: trunk/src/client/gui/shortcutwindow.h =================================================================== --- trunk/src/client/gui/shortcutwindow.h 2014-08-01 22:47:11 UTC (rev 9533) +++ trunk/src/client/gui/shortcutwindow.h 2014-08-02 21:58:47 UTC (rev 9534) @@ -127,6 +127,25 @@ */ bool LoadUserPrefs(); + void SetHPWarnLevel( float val ); + float GetHPWarnLevel(); + + void SetHPDangerLevel( float val ); + float GetHPDangerLevel(); + + void SetHPFlashLevel( float val ); + float GetHPFlashLevel(); + + void SetManaWarnLevel( float val ); + float GetManaWarnLevel(); + + void SetManaDangerLevel( float val ); + float GetManaDangerLevel(); + + void SetManaFlashLevel( float val ); + float GetManaFlashLevel(); + + protected: /// chat window for easy access pawsChatWindow* chatWindow; @@ -165,6 +184,7 @@ virtual void HandleMessage(MsgEntry *msg); + private: //status bars, optional;configured in XML pawsProgressBar *main_hp; Modified: trunk/src/common/paws/pawsprogressbar.cpp =================================================================== --- trunk/src/common/paws/pawsprogressbar.cpp 2014-08-01 22:47:11 UTC (rev 9533) +++ trunk/src/common/paws/pawsprogressbar.cpp 2014-08-02 21:58:47 UTC (rev 9534) @@ -269,7 +269,12 @@ flash_g = green; flash_b = blue; } +float pawsProgressBar::GetFlashLevel() +{ + return flashLevel; +} + void pawsProgressBar::SetReversed( bool val ) { reversed = val; @@ -283,6 +288,10 @@ warn_g = green; warn_b = blue; } +float pawsProgressBar::GetWarningLevel() +{ + return warnLevel; +} void pawsProgressBar::SetDanger( float level, bool low, int red, int green, int blue ) { @@ -292,5 +301,9 @@ danger_g = green; danger_b = blue; } +float pawsProgressBar::GetDangerLevel() +{ + return dangerLevel; +} Modified: trunk/src/common/paws/pawsprogressbar.h =================================================================== --- trunk/src/common/paws/pawsprogressbar.h 2014-08-01 22:47:11 UTC (rev 9533) +++ trunk/src/common/paws/pawsprogressbar.h 2014-08-02 21:58:47 UTC (rev 9534) @@ -60,6 +60,10 @@ */ virtual void SetFlash(float level, bool low, int rate, int red, int green, int blue ); + /** return the current "flash" level + */ + float GetFlashLevel(); + /** use a different primary color if above a certain threshold * @param level threshold * @param low if TRUE then active below this level; if FALSE active above. @@ -69,6 +73,10 @@ */ virtual void SetWarning( float level, bool low, int red, int green, int blue ); + /** return the current "Warn" level + */ + float GetWarningLevel(); + /** use a different primary color if above a certain threshold * @param level threshold * @param low if TRUE then active below this level; if FALSE active above. @@ -78,6 +86,10 @@ */ virtual void SetDanger( float level, bool low, int red, int green, int blue ); + /** return the current "Danger" level + */ + float GetDangerLevel(); + void Completed() { complete = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2014-08-03 05:36:27
|
Revision: 9535 http://sourceforge.net/p/planeshift/code/9535 Author: ralphcampbell Date: 2014-08-03 05:36:24 +0000 (Sun, 03 Aug 2014) Log Message: ----------- Add 'attack_type' to melee NPC behaviors so that bosses can have special attacks. The attack_type is a string which should be the name of the attack in the attacks database table. The NPC will use the same attack until the next melee operation changes the attack_type. Modified Paths: -------------- trunk/src/npcclient/networkmgr.cpp trunk/src/npcclient/networkmgr.h trunk/src/npcclient/npcoperations.cpp trunk/src/npcclient/npcoperations.h trunk/src/server/bulkobjects/psattack.cpp trunk/src/server/combatmanager.cpp trunk/src/server/gem.cpp trunk/src/server/gem.h trunk/src/server/npcmanager.cpp Modified: trunk/src/npcclient/networkmgr.cpp =================================================================== --- trunk/src/npcclient/networkmgr.cpp 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/npcclient/networkmgr.cpp 2014-08-03 05:36:24 UTC (rev 9535) @@ -2056,7 +2056,7 @@ cmd_count++; } -void NetworkManager::QueueAttackCommand(gemNPCActor* attacker, gemNPCActor* target, const char* stance) +void NetworkManager::QueueAttackCommand(gemNPCActor* attacker, gemNPCActor* target, const char* stance, const char* attack_type) { CheckCommandsOverrun(100); @@ -2075,6 +2075,11 @@ outbound->msg->Add(GetCommonStringID(stance)); + if(attack_type && attack_type[0]) + { + outbound->msg->Add(attack_type); + } + if(outbound->msg->overrun) { CS_ASSERT(!"NetworkManager::QueueAttackCommand put message in overrun state!\n"); Modified: trunk/src/npcclient/networkmgr.h =================================================================== --- trunk/src/npcclient/networkmgr.h 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/npcclient/networkmgr.h 2014-08-03 05:36:24 UTC (rev 9535) @@ -296,7 +296,7 @@ * @param target The target for the NPC or NULL to stop attack * @param stance The stance to be used */ - void QueueAttackCommand(gemNPCActor* attacker, gemNPCActor* target, const char* stance); + void QueueAttackCommand(gemNPCActor* attacker, gemNPCActor* target, const char* stance, const char* attack_type); /** * Send a script command to server Modified: trunk/src/npcclient/npcoperations.cpp =================================================================== --- trunk/src/npcclient/npcoperations.cpp 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/npcclient/npcoperations.cpp 2014-08-03 05:36:24 UTC (rev 9535) @@ -3261,8 +3261,8 @@ } else { - // Using the maximum allwed melee range of the server - // if none has been given by this operatoin. + // Using the maximum allowed melee range of the server + // if none has been given by this operation. melee_range = 3.0f; } @@ -3273,6 +3273,7 @@ } attackInvisible = node->GetAttributeValueAsBool("invisible",false); attackInvincible= node->GetAttributeValueAsBool("invincible",false); + attack_type = node->GetAttributeValue("attack_type"); stance = node->GetAttributeValue("stance"); // Default to normal stance @@ -3300,6 +3301,7 @@ op->attackInvisible = attackInvisible; op->attackInvincible = attackInvincible; op->stance = stance; + op->attack_type = attack_type; op->attackMostHatedTribeTarget = attackMostHatedTribeTarget; attacked_ent = NULL; return op; @@ -3307,7 +3309,8 @@ ScriptOperation::OperationResult MeleeOperation::Run(NPC* npc, bool interrupted) { - NPCDebug(npc, 5, "MeleeOperation starting with meele range %.2f seek range %.2f will attack:%s%s.", + csString type = psGameObject::ReplaceNPCVariables(npc, attack_type); + NPCDebug(npc, 5, "MeleeOperation starting with melee range %.2f seek range %.2f will attack:%s%s.", melee_range, seek_range,(attackInvisible?" Invisible":" Visible"), (attackInvincible?" Invincible":"")); @@ -3326,7 +3329,7 @@ { NPCDebug(npc, 5, "Melee starting to attack %s(%s)", attacked_ent->GetName(), ShowID(attacked_ent->GetEID())); - npcclient->GetNetworkMgr()->QueueAttackCommand(npc->GetActor(), attacked_ent, stance); + npcclient->GetNetworkMgr()->QueueAttackCommand(npc->GetActor(), attacked_ent, stance, type); } else { @@ -3408,7 +3411,8 @@ { NPCDebug(npc, 5, "Melee stop attack"); } - npcclient->GetNetworkMgr()->QueueAttackCommand(npc->GetActor(), ent, stance); + csString type = psGameObject::ReplaceNPCVariables(npc, attack_type); + npcclient->GetNetworkMgr()->QueueAttackCommand(npc->GetActor(), ent, stance, type); } // Make sure our rotation is still correct Modified: trunk/src/npcclient/npcoperations.h =================================================================== --- trunk/src/npcclient/npcoperations.h 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/npcclient/npcoperations.h 2014-08-03 05:36:24 UTC (rev 9535) @@ -1051,6 +1051,7 @@ csString attackOutsideRegion; ///< Attack even outside region if a region is defined. bool attackInvisible; bool attackInvincible; + csString attack_type; csString stance; csString attackMostHatedTribeTarget; ///< Melee operation "tribe" attribute. When set to true the ///< melee operation will use the most hated of all the tribe Modified: trunk/src/server/bulkobjects/psattack.cpp =================================================================== --- trunk/src/server/bulkobjects/psattack.cpp 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/server/bulkobjects/psattack.cpp 2014-08-03 05:36:24 UTC (rev 9535) @@ -430,7 +430,7 @@ if(!attack || !attack->CanAttack(attacker_client)) { // Use the default attack type. - attack = psserver->GetCacheManager()->GetAttackByID(1); + attack = psserver->GetCacheManager()->GetAttackByID(attacker->GetDefaultAttackID()); } // Schedule the next attack. @@ -484,7 +484,8 @@ if(DoLogDebug2(LOG_COMBAT, event->GetAttackerID())) { - CPrintf(CON_DEBUG, "Variables for Calculate Damage:\n"); + CPrintf(CON_DEBUG, "Variables for Calculate Damage (%s vs. %s):\n", + attacker->GetName(), target->GetName()); env.DumpAllVars(); } Modified: trunk/src/server/combatmanager.cpp =================================================================== --- trunk/src/server/combatmanager.cpp 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/server/combatmanager.cpp 2014-08-03 05:36:24 UTC (rev 9535) @@ -218,7 +218,7 @@ if(!attack || !attack->CanAttack(attacker->GetClient())) { // Use the default attack type. - attack = psserver->GetCacheManager()->GetAttackByID(1); + attack = psserver->GetCacheManager()->GetAttackByID(attacker->GetDefaultAttackID()); } if(weapon && weapon->CheckRequirements(attackerChar, response)) { Modified: trunk/src/server/gem.cpp =================================================================== --- trunk/src/server/gem.cpp 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/server/gem.cpp 2014-08-03 05:36:24 UTC (rev 9535) @@ -4653,6 +4653,7 @@ nextVeryShortRangeAvail = 0; /// When can npc respond to very short range prox trigger again nextShortRangeAvail = 0; /// When can npc respond to short range prox trigger again nextLongRangeAvail = 0; /// When can npc respond to long range prox trigger again + default_attackid = 1; speakers = 0; busy = false; Modified: trunk/src/server/gem.h =================================================================== --- trunk/src/server/gem.h 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/server/gem.h 2014-08-03 05:36:24 UTC (rev 9535) @@ -1300,7 +1300,6 @@ */ uint32_t activeMagic_seq; - public: psLinearMovement* pcmove; @@ -1381,6 +1380,13 @@ CS_ASSERT(attack_cnt); attack_cnt--; } + virtual void SetDefaultAttackID(unsigned) + { + } + virtual unsigned GetDefaultAttackID() + { + return 1; + } void SetSpellCasting(psSpellCastGameEvent* event) { @@ -1923,6 +1929,8 @@ csPDelArray<DialogCounter> badText; + unsigned default_attackid; ///< Default attack type ID + int speakers; bool busy; ///< Indicator from the NPC client to state the if the NPC is busy @@ -1937,6 +1945,14 @@ virtual ~gemNPC(); virtual void SetCombatStance(const Stance &stance); + virtual void SetDefaultAttackID(unsigned id) + { + default_attackid = id; + } + virtual unsigned GetDefaultAttackID() + { + return default_attackid; + } virtual const char* GetObjectType() { Modified: trunk/src/server/npcmanager.cpp =================================================================== --- trunk/src/server/npcmanager.cpp 2014-08-02 21:58:47 UTC (rev 9534) +++ trunk/src/server/npcmanager.cpp 2014-08-03 05:36:24 UTC (rev 9535) @@ -1040,6 +1040,14 @@ EID target_id = EID(list.msg->GetUInt32()); uint32_t stanceCSID = list.msg->GetUInt32(); // Common String ID csString stance = cacheManager->FindCommonString(stanceCSID); + unsigned attackid = 1; + if(list.msg->HasMore()) + { + const char* attack_type = list.msg->GetStr(); + psAttack* attack = cacheManager->GetAttackByName(attack_type); + if(attack) + attackid = attack->GetID(); + } Debug4(LOG_SUPERCLIENT, attacker_id.Unbox(), "-->Got %s attack cmd for entity %s to %s\n", stance.GetDataSafe(), ShowID(attacker_id), ShowID(target_id)); @@ -1081,6 +1089,7 @@ if(!target->GetClient() || !target->GetActorPtr()->GetInvincibility()) { + attacker->SetDefaultAttackID(attackid); if(psserver->combatmanager->AttackSomeone(attacker,target, CombatManager::GetStance(cacheManager, stance))) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2014-08-17 03:03:42
|
Revision: 9544 http://sourceforge.net/p/planeshift/code/9544 Author: ralphcampbell Date: 2014-08-17 03:03:32 +0000 (Sun, 17 Aug 2014) Log Message: ----------- Fix a few minor compiler warnings if --enable-debug is used. Modified Paths: -------------- trunk/src/client/gui/pawsconfigshortcut.cpp trunk/src/client/gui/pawsdndbutton.cpp trunk/src/client/gui/pawsscrollmenu.cpp trunk/src/client/gui/pawsscrollmenu.h trunk/src/common/music/musicxmlscore.cpp Modified: trunk/src/client/gui/pawsconfigshortcut.cpp =================================================================== --- trunk/src/client/gui/pawsconfigshortcut.cpp 2014-08-15 16:34:50 UTC (rev 9543) +++ trunk/src/client/gui/pawsconfigshortcut.cpp 2014-08-17 03:03:32 UTC (rev 9544) @@ -56,13 +56,13 @@ textSize(NULL), textSpacing(NULL), ShortcutMenu(NULL), + MenuBar(NULL), HPWarnLevel(NULL), HPDangerLevel(NULL), HPFlashLevel(NULL), ManaWarnLevel(NULL), ManaDangerLevel(NULL), - ManaFlashLevel(NULL), - MenuBar(NULL) + ManaFlashLevel(NULL) { loaded= false; } Modified: trunk/src/client/gui/pawsdndbutton.cpp =================================================================== --- trunk/src/client/gui/pawsdndbutton.cpp 2014-08-15 16:34:50 UTC (rev 9543) +++ trunk/src/client/gui/pawsdndbutton.cpp 2014-08-17 03:03:32 UTC (rev 9544) @@ -57,8 +57,6 @@ ImageNameCallback(NULL), NameCallback(NULL), ActionCallback(NULL), - DnDLock(false), - spellProgress(NULL), warnLevel(0.0), warnLow(false), warnMode(0), @@ -67,7 +65,9 @@ dangerMode(0), flashLevel(0.0), flashLow(false), - flashMode(0) + flashMode(0), + DnDLock(false), + spellProgress(NULL) { factory = "pawsDnDButton"; } Modified: trunk/src/client/gui/pawsscrollmenu.cpp =================================================================== --- trunk/src/client/gui/pawsscrollmenu.cpp 2014-08-15 16:34:50 UTC (rev 9543) +++ trunk/src/client/gui/pawsscrollmenu.cpp 2014-08-17 03:03:32 UTC (rev 9544) @@ -46,9 +46,6 @@ currentButton(0), paddingWidth(0), // scrollProportion(0.5), - warnLevel(0.0), - dangerLevel(0.0), - flashLevel(0.0), buttonWidthDynamic(true), ButtonHolder(NULL), buttonLocation(BUTTON_PADDING), @@ -62,7 +59,10 @@ EditLockMode(ScrollMenuOptionDISABLED), //enabled, disabled, (dynamic==>enabled) callbackWidget(NULL), scrollBarWidget(NULL), - Orientation(ScrollMenuOptionHORIZONTAL) + Orientation(ScrollMenuOptionHORIZONTAL), + warnLevel(0.0), + dangerLevel(0.0), + flashLevel(0.0) { } @@ -445,7 +445,7 @@ { return false; } - int i; + size_t i; for(i=currentButton; i<Buttons.GetSize() && Buttons[i]->GetScreenFrame().ymin==Buttons[currentButton]->GetScreenFrame().ymin; i++ ); currentButton=i; if( scrollBarWidget ) @@ -467,7 +467,7 @@ { currentButton=0; } - else if( currentButton>Buttons.GetSize()-1) + else if( currentButton>(int)Buttons.GetSize()-1) { currentButton=Buttons.GetSize()-1; } Modified: trunk/src/client/gui/pawsscrollmenu.h =================================================================== --- trunk/src/client/gui/pawsscrollmenu.h 2014-08-15 16:34:50 UTC (rev 9543) +++ trunk/src/client/gui/pawsscrollmenu.h 2014-08-17 03:03:32 UTC (rev 9544) @@ -214,7 +214,6 @@ int EditMode; float warnLevel; - bool warnLow; int warnMode; float dangerLevel; bool dangerLow; Modified: trunk/src/common/music/musicxmlscore.cpp =================================================================== --- trunk/src/common/music/musicxmlscore.cpp 2014-08-15 16:34:50 UTC (rev 9543) +++ trunk/src/common/music/musicxmlscore.cpp 2014-08-17 03:03:32 UTC (rev 9544) @@ -187,6 +187,8 @@ case FLAT: element += "<accidental>flat</accidental>"; break; + default: + break; } element += "</note>"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2014-09-13 18:01:55
|
Revision: 9563 http://sourceforge.net/p/planeshift/code/9563 Author: joelyon Date: 2014-09-13 18:01:34 +0000 (Sat, 13 Sep 2014) Log Message: ----------- modify 'renameable containers' code to support spaces in names and to trim name rather than failing if name length > 50. Modified Paths: -------------- trunk/src/client/cmdusers.cpp trunk/src/common/net/messages.cpp trunk/src/server/usermanager.cpp Modified: trunk/src/client/cmdusers.cpp =================================================================== --- trunk/src/client/cmdusers.cpp 2014-09-12 23:25:01 UTC (rev 9562) +++ trunk/src/client/cmdusers.cpp 2014-09-13 18:01:34 UTC (rev 9563) @@ -1364,13 +1364,12 @@ targetString = FormatTarget(words[1]); } } - if(!words[2].IsEmpty()){ - // hard coded check of the length of the new string - if(words[2].Length()>50){ - return "New name is too long" ; - } + if(!words[2].IsEmpty()) + { + csString cmdstring( cmd ); + targetString.Append(" "); - targetString.Append(words[2]); + targetString.Append( cmdstring.Slice( words[0].Length()+1+words[1].Length()+1, 50 ) ); } if (!targetString.IsEmpty()) { @@ -1381,7 +1380,7 @@ psUserCmdMessage cmdmsg(newCmd); cmdmsg.SendMessage(); }else{ - return "Usage /rename [item] [name] "; + return "Usage /rename [item] [name]"; } } else Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2014-09-12 23:25:01 UTC (rev 9562) +++ trunk/src/common/net/messages.cpp 2014-09-13 18:01:34 UTC (rev 9563) @@ -1379,7 +1379,8 @@ { valid = true; - WordArray words(message->GetStr()); + csString cmdstring( message->GetStr() ); + WordArray words(cmdstring.GetData()); command = words[0]; @@ -1538,8 +1539,8 @@ if(command == "/rename") { target = words.Get(1); - action = words.Get(2); - text = words.Get(3); + action = cmdstring.Slice( words[0].Length()+1+words[1].Length()+1, 50 ); + text = ""; return; } Modified: trunk/src/server/usermanager.cpp =================================================================== --- trunk/src/server/usermanager.cpp 2014-09-12 23:25:01 UTC (rev 9562) +++ trunk/src/server/usermanager.cpp 2014-09-13 18:01:34 UTC (rev 9563) @@ -2866,6 +2866,7 @@ // TODO: we need a macro for this guys if(target->Length() > 50){ psserver->SendSystemError(client->GetClientNum(), "New name is too long"); + return; } // Should check if it we are pointing somewhere safe... @@ -2888,7 +2889,6 @@ // database to test this... // set the name -fprintf(stderr, "*******UserManager::Rename '%s'\n", target->GetData() ); item->SetName(target->GetData()); // save the item This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2014-09-16 01:49:41
|
Revision: 9566 http://sourceforge.net/p/planeshift/code/9566 Author: joelyon Date: 2014-09-16 01:49:32 +0000 (Tue, 16 Sep 2014) Log Message: ----------- Natoka's doxygen_fix_comments.patch of 20140915 Modified Paths: -------------- trunk/src/common/music/musicxmlscore.h trunk/src/server/bulkobjects/psquestprereqops.h trunk/src/server/minigamemanager.h Modified: trunk/src/common/music/musicxmlscore.h =================================================================== --- trunk/src/common/music/musicxmlscore.h 2014-09-16 01:44:17 UTC (rev 9565) +++ trunk/src/common/music/musicxmlscore.h 2014-09-16 01:49:32 UTC (rev 9566) @@ -49,10 +49,10 @@ { public: /** - * Load a note from the given <note> node. If this element contain already one or - * more note, only notes that present the <chord/> tag are accepted. + * Load a note from the given \<note\> node. If this element contain already one or + * more note, only notes that present the \<chord/\> tag are accepted. * - * @param noteNode a reference to the <note> node containing the definition of the + * @param noteNode a reference to the \<note\> node containing the definition of the * note in MusicXML syntax. * @param divisions divisions per quarter used by the score to indicate duration. * @return false if the given node syntax is wrong or if this note is not part of @@ -69,4 +69,7 @@ #include "musicxmlscore.hpp" +/** + * @} */ + #endif // MUSIC_XML_SCORE_H Modified: trunk/src/server/bulkobjects/psquestprereqops.h =================================================================== --- trunk/src/server/bulkobjects/psquestprereqops.h 2014-09-16 01:44:17 UTC (rev 9565) +++ trunk/src/server/bulkobjects/psquestprereqops.h 2014-09-16 01:49:32 UTC (rev 9566) @@ -637,6 +637,8 @@ * @param categoryName The name of the category. * @param includeInventory if true it will search either equipment and inventory * else only inventory. + * @param amountMin A minimum amount. + * @param amountMax A maximum amount. * @param qualityMin A minimum quality. * @param qualityMax A maximum quality */ @@ -1478,6 +1480,7 @@ }; +/** + * @} */ - #endif Modified: trunk/src/server/minigamemanager.h =================================================================== --- trunk/src/server/minigamemanager.h 2014-09-16 01:44:17 UTC (rev 9565) +++ trunk/src/server/minigamemanager.h 2014-09-16 01:49:32 UTC (rev 9566) @@ -97,15 +97,15 @@ * MoveTo can be 'Vacancy' (player can move pieces to vacant squares only) * or 'Anywhere' (default - can move to any square, vacant or occupied). * - endgames: - * <MGEndGame> - * <EndGame Coords="relative"/"absolute" [SourceTile="T"] [Winner="T"]> - * <Coord Col="0-15" Row="0-15" Tile="T" [Piece="X"] /> - * </EndGame> - * </MGEndGame> + * \<MGEndGame\> + * \<EndGame Coords="relative"/"absolute" [SourceTile="T"] [Winner="T"]\> + * \<Coord Col="0-15" Row="0-15" Tile="T" [Piece="X"] /\> + * \</EndGame\> + * \</MGEndGame\> * where T : A = any valid piece / W = any white piece / B = any black piece * E = empty tile / F = follows source piece / S = specific pieces - * Each <EndGame> has 1 or more <Coord> spec. - * Each <MGEndGame> has 1 or more <EndGame>. + * Each \<EndGame\> has 1 or more \<Coord\> spec. + * Each \<MGEndGame\> has 1 or more \<EndGame\>. * Endgames can be left blank. * * The response string specifies the name to the record in gameboards This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2014-10-14 23:47:28
|
Revision: 9605 http://sourceforge.net/p/planeshift/code/9605 Author: joelyon Date: 2014-10-14 23:47:25 +0000 (Tue, 14 Oct 2014) Log Message: ----------- natoka's chatClickPatch_BugMenuNumbers_And_ByeClick_And_MenuRedisplayBugfix.patch bugs 6645, 6624 Modified Paths: -------------- trunk/src/client/gui/pawsnpcdialog.cpp trunk/src/server/bulkobjects/dictionary.cpp trunk/src/server/bulkobjects/dictionary.h trunk/src/server/questmanager.cpp Modified: trunk/src/client/gui/pawsnpcdialog.cpp =================================================================== --- trunk/src/client/gui/pawsnpcdialog.cpp 2014-10-14 23:28:15 UTC (rev 9604) +++ trunk/src/client/gui/pawsnpcdialog.cpp 2014-10-14 23:47:25 UTC (rev 9605) @@ -100,6 +100,7 @@ { clickedOnResponseBubble = false; NpcSays(); + gotNewMenu = false; } // if no new menu was sent by the server, request the default npc menu // this only works properly after the last message was given by the npc @@ -110,10 +111,12 @@ speechBubble->Hide(); FindWidget("FreeBubble")->Show(); psengine->GetCmdHandler()->Execute("/npcmenu"); - ticks = 0; + ticks = csGetTicks(); + timeDelay = 500; displaysNewMenu = false; } - } + } + else if (npcMsgQueue.GetSize() == 0 && (csGetTicks()-ticks > timeDelay || clickedOnResponseBubble)) { if (gotNewMenu && ! displaysNewMenu) @@ -133,9 +136,20 @@ Show(); displaysNewMenu = true; } - + else if (!gotNewMenu && csGetTicks()-ticks > timeDelay) + { + // if no new menu was sent by the server, request the default npc menu + Debug1(LOG_PAWS,0,"Hiding NPC speech and asking for another set of possible questions."); + speechBubble->Hide(); + FindWidget("FreeBubble")->Show(); + psengine->GetCmdHandler()->Execute("/npcmenu"); + ticks = csGetTicks(); + timeDelay = 500; + displaysNewMenu = false; + } } + SendToBottom(this); //printf("gotNewMenu: %d, ticks: %d timeDelay: %d\n",gotNewMenu?1:0, (csGetTicks()-ticks), timeDelay); @@ -301,11 +315,15 @@ CleanBubbles(); PawsManager::GetSingleton().SetCurrentFocusedWidget(textBox); ticks = csGetTicks(); // reset time, so we can wait for the next server response + timeDelay = 3000; // wait 3 seconds for new menu, otherwise request default npc menu gotNewMenu = false; } else if(name == "CloseBubble") { gotNewMenu = false; + npcMsgQueue.DeleteAll(); // drop all messages from server + ticks = csGetTicks(); + timeDelay = 0; // and reset the timer Hide(); } else if(name == "SpeechBubble") @@ -372,6 +390,7 @@ { unsigned int c = 1; csString bname = ""; + csString stepOf; //set text and visible bubbles for(unsigned int i = index; i < questInfo.GetSize() && c <= 3; i++, c++) @@ -382,7 +401,9 @@ pawsTextBox* qn = dynamic_cast<pawsTextBox*>(pb->FindWidget("QuestName")); pawsMultiLineTextBox* qt = dynamic_cast<pawsMultiLineTextBox*>(pb->FindWidget("QuestText")); - qn->SetText(questInfo[i].title); + stepOf.Format(" (%u/%u)", i+1, (unsigned int)questInfo.GetSize()); + + qn->SetText(questInfo[i].title + stepOf); qt->SetText(questInfo[i].text); pb->Show(); } Modified: trunk/src/server/bulkobjects/dictionary.cpp =================================================================== --- trunk/src/server/bulkobjects/dictionary.cpp 2014-10-14 23:28:15 UTC (rev 9604) +++ trunk/src/server/bulkobjects/dictionary.cpp 2014-10-14 23:47:25 UTC (rev 9605) @@ -2910,6 +2910,8 @@ csString currentQuest; size_t count = 0; + + //this->InitializeQuestTitles(); bool IsTesting = client->GetCharacterData()->GetActor()->questtester; bool IsGm = client->IsGM(); @@ -3029,26 +3031,7 @@ } } -void NpcDialogMenu::InitializeQuestTitles() -{ - csString questTitle; - csString questof; - for (size_t i=0; i < triggers.GetSize(); i++) - { - // only if questname is available, create <questname (1/x)> titles - if (triggers[i].quest && triggers[i].quest->GetName()) - { - questof.Format(" (%u of %u)", (int) i+1, (int) triggers.GetSize()); - triggers[i].questTitle = triggers[i].quest->GetName() + questof; - } - } -} - csString NpcDialogMenu::DialogTrigger::GetQuestTitle() { - if (questTitle.IsEmpty()) - { - return quest ? quest->GetName() : "(Unknown)"; - } - return questTitle; + return quest ? quest->GetName() : "(Unknown)"; } Modified: trunk/src/server/bulkobjects/dictionary.h =================================================================== --- trunk/src/server/bulkobjects/dictionary.h 2014-10-14 23:28:15 UTC (rev 9604) +++ trunk/src/server/bulkobjects/dictionary.h 2014-10-14 23:47:25 UTC (rev 9605) @@ -328,18 +328,16 @@ struct DialogTrigger { unsigned int triggerID; ///< internal trigger identifier - csString questTitle; ///< title - with numbers (1 of ...) csString menuText; ///< text of the menu entry csString trigger; ///< actual trigger text psQuest* quest; ///< quest that the trigger refers to csRef<psQuestPrereqOp> prerequisite; - /** - * retrive the title of the specified trigger. - * A set questTitle takes preceedence over fetching - * the questtitle automatically from the given quest - */ + /* returns the quest title + * @return the quest title if quest is set, otherwise "unknown" + */ csString GetQuestTitle(); + DialogTrigger() : quest(NULL) {} }; @@ -386,13 +384,6 @@ * @param script the prerequisites that are to be set. */ void SetPrerequisiteScript(csRef<psQuestPrereqOp> script); - - /** - * Initializes the Questtitles of the array. - * Should only be used when storing triggers for one quest, - * otherwise counting the triggers will - */ - void InitializeQuestTitles(); }; /** Modified: trunk/src/server/questmanager.cpp =================================================================== --- trunk/src/server/questmanager.cpp 2014-10-14 23:28:15 UTC (rev 9604) +++ trunk/src/server/questmanager.cpp 2014-10-14 23:47:25 UTC (rev 9605) @@ -1583,7 +1583,7 @@ start = end; // Start at next Menu: or exit loop } - menu->InitializeQuestTitles(); + return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2014-11-09 18:52:20
|
Revision: 9644 http://sourceforge.net/p/planeshift/code/9644 Author: ralphcampbell Date: 2014-11-09 18:52:12 +0000 (Sun, 09 Nov 2014) Log Message: ----------- Fix character creation selection of siblings. The database has to have the ID number increasing so the data sent to the client is in the desired order. The server has to sort the database queries by ID so the database lookup doesn't reorder them. The client has to Show() or Hide() the unused radio buttons. Modified Paths: -------------- trunk/src/client/gui/pawscharbirth.cpp trunk/src/server/creationmanager.cpp trunk/src/server/database/mysql/char_creation.sql Modified: trunk/src/client/gui/pawscharbirth.cpp =================================================================== --- trunk/src/client/gui/pawscharbirth.cpp 2014-11-09 07:38:58 UTC (rev 9643) +++ trunk/src/client/gui/pawscharbirth.cpp 2014-11-09 18:52:12 UTC (rev 9644) @@ -34,8 +34,11 @@ #define MONTH_COMBOBOX 5 #define NEXT_BUTTON 5000 #define BACK_BUTTON 6000 +#define RANDOMIZE_BUTTON 7000 //////////////////////////////////////////////////////////////////////////////// +// This should match the number of radio buttons in data/gui/birth.xml +#define MAXSIBLINGS 4 pawsCharBirth::pawsCharBirth(): cpBox(NULL),months(NULL),days(NULL) @@ -134,15 +137,14 @@ return true; } - if ( strcmp(widget->GetName(),"randomize") == 0 ) - { - Randomize(); - return true; - } - int id = widget->GetID(); switch ( id ) { + case RANDOMIZE_BUTTON: + { + Randomize(); + return true; + } case BACK_BUTTON: { Hide(); @@ -221,6 +223,8 @@ char widgetName[100]; sprintf( widgetName, "sibling%d", sibCount ); pawsRadioButton* button = (pawsRadioButton*)FindWidget( widgetName ); + if (!button) + continue; button->SetID( createManager->childhoodData[x].id ); button->Show(); pawsTextBox* name = button->GetTextBox(); @@ -241,11 +245,19 @@ } } } + // Hide unused sibling radio buttons. + for (int i = sibCount; i < MAXSIBLINGS; i++) + { + char widgetName[100]; + sprintf( widgetName, "sibling%d", i ); + pawsRadioButton* button = (pawsRadioButton*)FindWidget( widgetName ); + if (button) + button->Hide(); + } } void pawsCharBirth::Draw() { - pawsWidget::Draw(); // Check to see if we are waiting for data from the server. Should have a waiting // cursor if this fails. if (!dataLoaded && createManager->HasChildhoodData()) @@ -258,6 +270,7 @@ dataLoaded = true; } + pawsWidget::Draw(); } void pawsCharBirth::OnListAction( pawsListBox* widget, int status ) Modified: trunk/src/server/creationmanager.cpp =================================================================== --- trunk/src/server/creationmanager.cpp 2014-11-09 07:38:58 UTC (rev 9643) +++ trunk/src/server/creationmanager.cpp 2014-11-09 18:52:12 UTC (rev 9644) @@ -226,7 +226,7 @@ bool CharCreationManager::LoadCreationChoices() { - Result result(db->Select("SELECT * from character_creation")); + Result result(db->Select("SELECT * from character_creation order by id")); if(!result.IsValid() || result.Count() == 0) return false; Modified: trunk/src/server/database/mysql/char_creation.sql =================================================================== --- trunk/src/server/database/mysql/char_creation.sql 2014-11-09 07:38:58 UTC (rev 9643) +++ trunk/src/server/database/mysql/char_creation.sql 2014-11-09 18:52:12 UTC (rev 9644) @@ -76,32 +76,33 @@ "charcreate_3", "CHILD_HOUSE" ); - - + +# The database ID value determines the order of the radio buttons + INSERT INTO character_creation VALUES("8", + "None", + "You are the only child", + 6, + "charcreate_3", + "CHILD_SIBLINGS" + ); + +INSERT INTO character_creation VALUES("9", "One", - "Just the one other child in your family", + "One other child in your family", 6, "charcreate_3", "CHILD_SIBLINGS" ); -INSERT INTO character_creation VALUES("9", +INSERT INTO character_creation VALUES("10", "Two", - "Two childs and you in your family", + "Two children besides you in your family", 6, "charcreate_2", "CHILD_SIBLINGS" ); -INSERT INTO character_creation VALUES("10", - "None", - "All alone", - 6, - "charcreate_3", - "CHILD_SIBLINGS" - ); - INSERT INTO character_creation VALUES (215,'Unodin','','-1','charcreate_215','ZODIAC'); INSERT INTO character_creation VALUES (216,'Byari','','-2','charcreate_216','ZODIAC'); INSERT INTO character_creation VALUES (217,'Treman','','-3','charcreate_217','ZODIAC'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2014-11-09 20:37:30
|
Revision: 9646 http://sourceforge.net/p/planeshift/code/9646 Author: ralphcampbell Date: 2014-11-09 20:37:28 +0000 (Sun, 09 Nov 2014) Log Message: ----------- Fix 6691 - Action location: Rotation not set correct when the AL crosses a map. Modified Paths: -------------- trunk/src/client/psclientdr.cpp trunk/src/client/zonehandler.cpp trunk/src/common/net/messages.cpp trunk/src/common/net/messages.h Modified: trunk/src/client/psclientdr.cpp =================================================================== --- trunk/src/client/psclientdr.cpp 2014-11-09 20:22:24 UTC (rev 9645) +++ trunk/src/client/psclientdr.cpp 2014-11-09 20:37:28 UTC (rev 9646) @@ -238,7 +238,7 @@ if(last_sector != msg.sectorName) { psengine->GetZoneHandler()->HandleDelayAndAnim(msg.loadTime, msg.start, msg.dest, msg.backgroundname, msg.loadWidget); - psNewSectorMessage cross(last_sector, msg.sectorName, msg.pos); + psNewSectorMessage cross(last_sector, msg.sectorName, msg.pos, true, msg.yrot); msghandler->Publish(cross.msg); Error3("Sector crossed from %s to %s after forced position update.\n", last_sector.GetData(), msg.sectorName.GetData()); } Modified: trunk/src/client/zonehandler.cpp =================================================================== --- trunk/src/client/zonehandler.cpp 2014-11-09 20:22:24 UTC (rev 9645) +++ trunk/src/client/zonehandler.cpp 2014-11-09 20:37:28 UTC (rev 9646) @@ -195,12 +195,13 @@ Notify3(LOG_LOAD, "Crossed from sector %s to sector %s.", msg.oldSector.GetData(), msg.newSector.GetData()); csVector3 velocity = csVector3(0.0f); - float yrot = 0.0f; + float yrot = msg.yrot; // load current speed on sector crossing if the player is valid (not during game loading) if(celclient->GetMainPlayer()) { velocity = celclient->GetMainPlayer()->GetVelocity(); - yrot = celclient->GetMainPlayer()->GetYRotation(); + if(!msg.use_yrot) + yrot = celclient->GetMainPlayer()->GetYRotation(); } LoadZone(msg.pos, yrot, msg.newSector, velocity); Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2014-11-09 20:22:24 UTC (rev 9645) +++ trunk/src/common/net/messages.cpp 2014-11-09 20:37:28 UTC (rev 9646) @@ -2550,9 +2550,12 @@ PSF_IMPLEMENT_MSG_FACTORY(psNewSectorMessage,MSGTYPE_NEWSECTOR); -// Leaving this one marshalled the old way. This message is NEVER sent on -// the network. -psNewSectorMessage::psNewSectorMessage(const csString &oldSector, const csString &newSector, csVector3 pos) +// This message is NEVER sent on the network but it is sent within the client. +psNewSectorMessage::psNewSectorMessage(const csString &oldSector, + const csString &newSector, + csVector3 pos, + bool use_yrot, + float yrot) { msg.AttachNew(new MsgEntry(1024)); @@ -2564,6 +2567,8 @@ msg->Add(pos.x); msg->Add(pos.y); msg->Add(pos.z); + msg->Add(use_yrot); + msg->Add(yrot); // Since this message is never sent, we don't adjust the valid flag } @@ -2579,6 +2584,8 @@ pos.x = message->GetFloat(); pos.y = message->GetFloat(); pos.z = message->GetFloat(); + use_yrot = message->GetBool(); + yrot = message->GetFloat(); // Since this message is never sent, we don't adjust the valid flag } @@ -2587,8 +2594,9 @@ { csString msgtext; - msgtext.AppendFmt("Old sector: '%s' New sector: '%s' Pos: (%.3f,%.3f,%.3f)", - oldSector.GetDataSafe(), newSector.GetDataSafe(), pos.x, pos.y, pos.z); + msgtext.AppendFmt("Old sector: '%s' New sector: '%s' Pos: (%.3f,%.3f,%.3f) use YRot: %d YRot: %.3f", + oldSector.GetDataSafe(), newSector.GetDataSafe(), + pos.x, pos.y, pos.z, use_yrot, yrot); return msgtext; } Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2014-11-09 20:22:24 UTC (rev 9645) +++ trunk/src/common/net/messages.h 2014-11-09 20:37:28 UTC (rev 9646) @@ -1782,7 +1782,7 @@ class psNewSectorMessage : public psMessageCracker { public: - psNewSectorMessage(const csString &oldSector, const csString &newSector, csVector3 pos); + psNewSectorMessage(const csString &oldSector, const csString &newSector, csVector3 pos, bool use_yrot = false, float yrot = 0.0); psNewSectorMessage(MsgEntry* message); PSF_DECLARE_MSG_FACTORY(); @@ -1799,6 +1799,8 @@ /// Holds the options that the window should display. csString oldSector, newSector; csVector3 pos; + float yrot; ///< Rotation around Y-axis in radians + bool use_yrot; ///< Use the yrot value to set the rotation }; //--------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2014-11-25 05:15:38
|
Revision: 9659 http://sourceforge.net/p/planeshift/code/9659 Author: joelyon Date: 2014-11-25 05:15:35 +0000 (Tue, 25 Nov 2014) Log Message: ----------- Venalan's patch to prevent the "Use" icon appearing in interact or item menus if the container has the "CANTRANSFORM" flag. Modified Paths: -------------- trunk/src/client/gui/pawscontainerdescwindow.cpp trunk/src/common/net/messages.cpp trunk/src/common/net/messages.h trunk/src/server/actionmanager.cpp trunk/src/server/bulkobjects/psitem.cpp trunk/src/server/bulkobjects/psitem.h Modified: trunk/src/client/gui/pawscontainerdescwindow.cpp =================================================================== --- trunk/src/client/gui/pawscontainerdescwindow.cpp 2014-11-22 22:43:43 UTC (rev 9658) +++ trunk/src/client/gui/pawscontainerdescwindow.cpp 2014-11-25 05:15:35 UTC (rev 9659) @@ -133,7 +133,13 @@ FindWidget("EnableEditName")->Hide(); FindWidget("SendEditName")->Hide(); } - + + // check whether the CanTransform flag is set, if so, show the use button + if(mesg.CanTransform==true){ + FindWidget("UseContainer")->Hide(); + }else{ + FindWidget("UseContainer")->Show(); + } // default display configuration for container editName->Hide(); name->Show(); Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2014-11-22 22:43:43 UTC (rev 9658) +++ trunk/src/common/net/messages.cpp 2014-11-25 05:15:35 UTC (rev 9659) @@ -6187,7 +6187,8 @@ sizeof(int32_t) + // container ID sizeof(int32_t) + // slot id sizeof(uint32_t) + // stack count - sizeof(bool)); // is renameable + sizeof(bool) + // is renameable + sizeof(bool)); // AutoTransform } void psViewContainerDescription::AddContents(const char* name, const char* meshName, const char* materialName, const char* icon, int purifyStatus, int slot, int stack) @@ -6232,6 +6233,7 @@ msg->Add((uint32_t)contents[n].stackCount); } msg->Add(renameable); + msg->Add(CanTransform); } psViewContainerDescription::psViewContainerDescription(MsgEntry* me, NetBase::AccessPointers* accessPointers) @@ -6279,6 +6281,7 @@ } } renameable = me->GetBool(); + CanTransform = me->GetBool(); } } Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2014-11-22 22:43:43 UTC (rev 9658) +++ trunk/src/common/net/messages.h 2014-11-25 05:15:35 UTC (rev 9659) @@ -4401,6 +4401,9 @@ /// indicates whether the container is renameable or not bool renameable; + /// indicates whether the container can auto transform or not + bool CanTransform; + /// The destination client for this message. int to; Modified: trunk/src/server/actionmanager.cpp =================================================================== --- trunk/src/server/actionmanager.cpp 2014-11-22 22:43:43 UTC (rev 9658) +++ trunk/src/server/actionmanager.cpp 2014-11-25 05:15:35 UTC (rev 9659) @@ -735,7 +735,8 @@ if(realItem->IsConstructible()) options |= psGUIInteractMessage::CONSTRUCT; // All other action location items can be used - options |= psGUIInteractMessage::USE; + if(!(realItem->GetCanTransform())) + options |= psGUIInteractMessage::USE; } options |= psGUIInteractMessage::CLOSE; Modified: trunk/src/server/bulkobjects/psitem.cpp =================================================================== --- trunk/src/server/bulkobjects/psitem.cpp 2014-11-22 22:43:43 UTC (rev 9658) +++ trunk/src/server/bulkobjects/psitem.cpp 2014-11-25 05:15:35 UTC (rev 9659) @@ -3275,6 +3275,7 @@ outgoing.maxContainerSlots = GetContainerMaxSlots(); outgoing.renameable = GetBaseStats()->GetIsRenameable(); + outgoing.CanTransform = GetBaseStats()->GetCanTransform(); FillContainerMsg(client, outgoing); outgoing.ConstructMsg(psserver->GetCacheManager()->GetMsgStrings()); Modified: trunk/src/server/bulkobjects/psitem.h =================================================================== --- trunk/src/server/bulkobjects/psitem.h 2014-11-22 22:43:43 UTC (rev 9658) +++ trunk/src/server/bulkobjects/psitem.h 2014-11-25 05:15:35 UTC (rev 9659) @@ -783,6 +783,7 @@ bool GetIsArmor(); bool GetIsShield(); bool GetIsContainer(); + bool GetIsAutoTransformContainer(); bool GetIsTrap(); bool GetIsConstructible(); bool GetCanTransform(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2015-01-01 06:35:47
|
Revision: 9687 http://sourceforge.net/p/planeshift/code/9687 Author: ralphcampbell Date: 2015-01-01 06:35:39 +0000 (Thu, 01 Jan 2015) Log Message: ----------- Change the server to hide the crafing/lockpicking timer window if the operation is interrupted. Although there is a client side change, it is really an optimization and old client should work OK with the new server. The difference is that the pawsCraftCancelWindow might be displayed for a millisecond. Modified Paths: -------------- trunk/src/client/gui/pawscraftcancelwindow.cpp trunk/src/server/workmanager.cpp Modified: trunk/src/client/gui/pawscraftcancelwindow.cpp =================================================================== --- trunk/src/client/gui/pawscraftcancelwindow.cpp 2014-12-30 18:54:14 UTC (rev 9686) +++ trunk/src/client/gui/pawscraftcancelwindow.cpp 2015-01-01 06:35:39 UTC (rev 9687) @@ -72,6 +72,13 @@ void pawsCraftCancelWindow::Start(csTicks craftTime) { + if (craftTime == 0) + { + this->craftTime = 0; + Hide(); + return; + } + craftProgress->SetCurrentValue(0.0); startTime = csGetTicks(); this->craftTime = craftTime * 1000; Modified: trunk/src/server/workmanager.cpp =================================================================== --- trunk/src/server/workmanager.cpp 2014-12-30 18:54:14 UTC (rev 9686) +++ trunk/src/server/workmanager.cpp 2015-01-01 06:35:39 UTC (rev 9687) @@ -4233,6 +4233,9 @@ if(object) object->SetInUse(false); } + psCraftCancelMessage msg; + msg.SetCraftTime(0, client->GetClientNum()); + msg.SendMessage(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2015-01-10 20:50:05
|
Revision: 9692 http://sourceforge.net/p/planeshift/code/9692 Author: ralphcampbell Date: 2015-01-10 20:49:57 +0000 (Sat, 10 Jan 2015) Log Message: ----------- The server was changed to always send a MSGTYPE_DIALOG_MENU message so that the client would display a text input box for KA responses if it had NPC chat bubbles enabled. This was causing the client to display an empty NPC dialog menu if NPC chat bubbles was not enabled. So just changing the server to not send the MSGTYPE_DIALOG_MENU message if there are no quest responses (to fix the empty dialog menu), isn't a complete solution. The fix here is to "do both". Change the client so that the menu isn't displayed if it is empty and change the server to send the empty MSGTYPE_DIALOG_MENU message but also send the text info message that "This NPC has no quest for you, but might have other things to say." Note that both the client and server need to be updated together to see this behavior. Modified Paths: -------------- trunk/src/client/gui/pawsnpcdialog.cpp trunk/src/server/bulkobjects/dictionary.cpp Modified: trunk/src/client/gui/pawsnpcdialog.cpp =================================================================== --- trunk/src/client/gui/pawsnpcdialog.cpp 2015-01-08 08:48:25 UTC (rev 9691) +++ trunk/src/client/gui/pawsnpcdialog.cpp 2015-01-10 20:49:57 UTC (rev 9692) @@ -581,13 +581,14 @@ { LoadQuest(mesg.xml); giveBubble->Show(); + Show(); } else { AdjustForPromptWindow(); + if(responseList->GetRowCount()) + Show(); } - - Show(); } else if(me->GetType() == MSGTYPE_CHAT) { Modified: trunk/src/server/bulkobjects/dictionary.cpp =================================================================== --- trunk/src/server/bulkobjects/dictionary.cpp 2015-01-08 08:48:25 UTC (rev 9691) +++ trunk/src/server/bulkobjects/dictionary.cpp 2015-01-10 20:49:57 UTC (rev 9692) @@ -3000,6 +3000,14 @@ else { psserver->SendSystemError(client->GetClientNum(), "This NPC has no quest for you, but might have other things to say."); + // Send an empty message if there are possibly KAs. + // This message can be used by clients with NPC dialog bubbles enabled + // to display a text input box but not display an empty NPC dialog menu. + if(triggers.GetSize()) + { + menu.BuildMsg(client->GetClientNum()); + psserver->GetNetManager()->SendMessageDelayed(menu.msg, delay); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2015-02-11 03:34:41
|
Revision: 9709 http://sourceforge.net/p/planeshift/code/9709 Author: joelyon Date: 2015-02-11 03:34:33 +0000 (Wed, 11 Feb 2015) Log Message: ----------- OS information is now broken into seperate db fields : os (contains the initial character of 'MacOS', 'Unix' or 'Windows'), major version, minor version, platform information (for Mac, unix/linux - specifies flavor or build info), machine type (ex, x86_64, x86_32) Modified Paths: -------------- trunk/src/client/authentclient.cpp trunk/src/common/net/messages.cpp trunk/src/common/net/messages.h trunk/src/common/net/npcmessages.cpp trunk/src/server/authentserver.cpp trunk/src/server/bulkobjects/psaccountinfo.cpp trunk/src/server/bulkobjects/psaccountinfo.h trunk/src/server/cachemanager.cpp trunk/src/server/database/mysql/accounts.sql Modified: trunk/src/client/authentclient.cpp =================================================================== --- trunk/src/client/authentclient.cpp 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/client/authentclient.cpp 2015-02-11 03:34:33 UTC (rev 9709) @@ -220,16 +220,58 @@ iGraphics2D *graphics2D = PawsManager::GetSingleton().GetGraphics3D()->GetDriver2D(); csString HWRender = graphics2D->GetHWRenderer(); csString HWGLVersion = graphics2D->GetHWGLVersion(); - char SysString[32]; -#ifdef CS_PLATFORM_MACOSX + + char OS[2] = { 0,0 }, + OS_platform[15] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } , + machine_type[7] = { 0,0,0,0,0,0,0 }, + *s, + *t; + + uint16 OS_ver_major, + OS_ver_minor; + +#ifndef _WINDOWS uname(&SYSinfo); - char *s=strstr( SYSinfo.version, "root:" )+5; - sprintf( SysString, "M%5.5s%6.6s %14.14s", SYSinfo.release, SYSinfo.machine, s ); -#elif defined(CS_PLATFORM_UNIX) - uname (&SYSinfo); - char *s=SYSinfo.version; - sprintf( SysString, "%1.1s %4.4s%6.6s %14.14s", SYSinfo.sysname, SYSinfo.release, SYSinfo.machine, s ); + +# ifdef CS_PLATFORM_MACOSX + OS[0]='M'; + OS_platform[0]=0; + s=strstr( SYSinfo.version, "root:" )+5; + sprintf( OS_platform, "%14.14s", s ); +# elif defined(CS_PLATFORM_UNIX) + OS[0]='U'; + sprintf( OS_platform, "%14.14s", SYSinfo.version ); +# endif + + s=SYSinfo.release; + t=strstr( s, "." ); + if( t!=NULL ) + { + *t=0; + OS_ver_major=atoi(s); + + s=t+1; + t=strstr( s, "." ); + if( t!=NULL ) + { + *t=0; + OS_ver_minor=atoi(s); + } + else + { + OS_ver_minor=atoi(s); + } + } + else + { + OS_ver_major=atoi(s); + } + + + sprintf( machine_type, "%6.6s", SYSinfo.machine ); + #elif defined(_WINDOWS) + OS[0]='W'; OSVERSIONINFO osvi; SYSTEM_INFO si; PGNSI pGNSI; @@ -240,8 +282,11 @@ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi); //fields : OS, MajorRev, MinorRev, architecture, platform - if( ! bOsVersionInfoEx ) { - sprintf( SysString, "%1.1s??.?? %2.2s.%2.2s %s", CS_PLATFORM_NAME, CS_PROCESSOR_NAME,CS_PROCESSOR_SIZE,CS_COMPILER_NAME ); + if( ! bOsVersionInfoEx ) + { + OS_ver_major=0; + OS_ver_minor=0; + sprintf( machine_type, "x%2.2s_2.2s", CS_PROCESSOR_NAME,CS_PROCESSOR_SIZE ); } else { @@ -254,17 +299,25 @@ pGNSI(&si); else GetSystemInfo(&si); - sprintf(SysString, "W% 2d.% 2d%06.0d", osvi.dwMajorVersion, osvi.dwMinorVersion, si.dwProcessorType ); //8664 = x86_64 - + OS_ver_major=osvi.dwMajorVersion + OS_ver_minor=osvi.dwMinorVersion; + if( si.dwProcessorType==8664 ) + { + sprintf( machine_type, "x86_64" ); + } + else if( si.dwProcessorType==8632 ) + { + sprintf( machine_type, "x86_32" ); + } + else + { + sprintf( machine_type, "% 6i", si.dwProcessorType ); + } } -#else - //default back to old information taken not from the currently executing machine but the client compile env. - sprintf( SysString, "%1.1s??.?? %2.2s.%2.2s %s", CS_PLATFORM_NAME, CS_PROCESSOR_NAME,CS_PROCESSOR_SIZE,CS_COMPILER_NAME ); + OS_platform[0]=0; #endif - SysString[31]=0; //just to make sure... - psAuthenticationMessage request(0,username.GetData(), hexstring.GetData(), SysString, HWRender.GetDataSafe(), HWGLVersion.GetDataSafe(), "" ); - - request.SendMessage(); + psAuthenticationMessage request(0,username.GetData(), hexstring.GetData(), OS, OS_ver_major, OS_ver_minor, OS_platform, machine_type, HWRender.GetDataSafe(), HWGLVersion.GetDataSafe(), "" ); + request.SendMessage(); } Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/common/net/messages.cpp 2015-02-11 03:34:33 UTC (rev 9709) @@ -154,7 +154,7 @@ PSF_IMPLEMENT_MSG_FACTORY(psAuthenticationMessage,MSGTYPE_AUTHENTICATE); psAuthenticationMessage::psAuthenticationMessage(uint32_t clientnum, - const char* userid,const char* password, const char* os, const char* gfxcard, const char* gfxversion, const char* password256, uint32_t version) + const char* userid,const char* password, const char* os, uint16 os_ver_major, uint16 os_ver_minor, const char *os_platform, const char * machine_type, const char* gfxcard, const char* gfxversion, const char* password256, uint32_t version) { if(!userid || !password) @@ -164,7 +164,7 @@ } - msg.AttachNew(new MsgEntry(strlen(userid)+1+strlen(password)+1+strlen(os)+1+strlen(gfxcard)+1+strlen(gfxversion)+1+strlen(password256)+1+sizeof(uint32_t),PRIORITY_LOW)); + msg.AttachNew(new MsgEntry(strlen(userid)+1+strlen(password)+1+strlen(os)+1+sizeof(os_ver_major)+sizeof(os_ver_minor)+strlen(os_platform)+1+strlen(machine_type)+1+strlen(gfxcard)+1+strlen(gfxversion)+1+strlen(password256)+1+sizeof(uint32_t),PRIORITY_LOW)); msg->SetType(MSGTYPE_AUTHENTICATE); msg->clientnum = clientnum; @@ -173,6 +173,10 @@ msg->Add(userid); msg->Add(password); msg->Add(os); + msg->Add(os_ver_major); + msg->Add(os_ver_minor); + msg->Add(os_platform); + msg->Add(machine_type); msg->Add(gfxcard); msg->Add(gfxversion); msg->Add(password256); @@ -190,6 +194,10 @@ sUser = message->GetStr(); sPassword = message->GetStr(); os_ = message->GetStr(); + os_ver_major = message->GetUInt16(); + os_ver_minor = message->GetUInt16(); + os_platform = message->GetStr(); + machine_type = message->GetStr(); gfxcard_ = message->GetStr(); gfxversion_ = message->GetStr(); if(!message->IsEmpty()) Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/common/net/messages.h 2015-02-11 03:34:33 UTC (rev 9709) @@ -588,10 +588,16 @@ { public: uint32_t netversion; - csString sAddr; - csString sUser,sPassword; - csString sPassword256; - csString os_, gfxcard_, gfxversion_; + csString sAddr, + sUser, + sPassword, + sPassword256, + os_, + os_platform, + machine_type, + gfxcard_, gfxversion_; + uint16 os_ver_major, + os_ver_minor; /** * This function creates a PS Message struct given a userid and @@ -599,7 +605,7 @@ * creation when a user wants to log in. */ psAuthenticationMessage(uint32_t clientnum,const char* userid, - const char* password, const char* os, const char* gfxcard, const char* gfxversion, const char* sPassword256 = "", uint32_t version=PS_NETVERSION); + const char* password, const char* os, uint16 os_ver_major, uint16 os_ver_minor, const char *os_platform, const char *machine_type, const char* gfxcard, const char* gfxversion, const char* sPassword256 = "", uint32_t version=PS_NETVERSION); /** * This constructor receives a PS Message struct and cracks it apart Modified: trunk/src/common/net/npcmessages.cpp =================================================================== --- trunk/src/common/net/npcmessages.cpp 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/common/net/npcmessages.cpp 2015-02-11 03:34:33 UTC (rev 9709) @@ -36,7 +36,7 @@ psNPCAuthenticationMessage::psNPCAuthenticationMessage(uint32_t clientnum, const char *userid, const char *password) -: psAuthenticationMessage(clientnum,userid,password,"NPC", "NPC", "NPC", "", PS_NPCNETVERSION) +: psAuthenticationMessage(clientnum,userid,password,"NPC", 0, 0, "NPC", "NPC", "NPC", "NPC", "", PS_NPCNETVERSION) { /* * This structure is exactly like the regular authentication message, Modified: trunk/src/server/authentserver.cpp =================================================================== --- trunk/src/server/authentserver.cpp 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/server/authentserver.cpp 2015-02-11 03:34:33 UTC (rev 9709) @@ -440,9 +440,13 @@ gmtm->tm_sec); acctinfo->lastlogintime = timeStr; - acctinfo->os = msg.os_; - acctinfo->gfxcard = msg.gfxcard_; - acctinfo->gfxversion = msg.gfxversion_; + acctinfo->os = msg.os_; + acctinfo->os_ver_major = msg.os_ver_major; + acctinfo->os_ver_minor = msg.os_ver_minor; + acctinfo->os_platform = msg.os_platform; + acctinfo->machine_type = msg.machine_type; + acctinfo->gfxcard = msg.gfxcard_; + acctinfo->gfxversion = msg.gfxversion_; psserver->GetCacheManager()->UpdateAccountInfo(acctinfo); iCachedObject* obj = psserver->GetCacheManager()->RemoveFromCache(psserver->GetCacheManager()->MakeCacheName("auth",acctinfo->accountid)); Modified: trunk/src/server/bulkobjects/psaccountinfo.cpp =================================================================== --- trunk/src/server/bulkobjects/psaccountinfo.cpp 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/server/bulkobjects/psaccountinfo.cpp 2015-02-11 03:34:33 UTC (rev 9709) @@ -53,7 +53,12 @@ createddate = row["created_date"]; lastlogintime = row["last_login"]; lastloginip = row["last_login_ip"]; - os = row["operating_system"]; + os = row["OS"]; + os_ver_major = row.GetInt("OS_ver_major"); + os_ver_minor = row.GetInt("OS_ver_minor"); + os_platform = row["OS_platform"]; + machine_type = row["Machine_type"]; + gfxcard = row["graphics_card"]; gfxversion = row["graphics_version"]; Modified: trunk/src/server/bulkobjects/psaccountinfo.h =================================================================== --- trunk/src/server/bulkobjects/psaccountinfo.h 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/server/bulkobjects/psaccountinfo.h 2015-02-11 03:34:33 UTC (rev 9709) @@ -77,8 +77,18 @@ csString createddate; /// String value of the last ip a connection came in from csString lastloginip; + /// String containing the os the connecting machine is running csString os; + /// String containing the os major version the connecting machine is running + uint16 os_ver_major; + /// String containing the os minor version the connecting machine is running + uint16 os_ver_minor; + /// String containing miscellaneous details about the os the connecting machine is running + csString os_platform; + /// String containing the type of connecting machine + csString machine_type; + /// String containing the graphics card the connecting machine is using csString gfxcard; /// String containing the graphics driver version the connecting machine is using; Modified: trunk/src/server/cachemanager.cpp =================================================================== --- trunk/src/server/cachemanager.cpp 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/server/cachemanager.cpp 2015-02-11 03:34:33 UTC (rev 9709) @@ -3965,7 +3965,11 @@ "last_login_ip", "security_level", "last_login", - "operating_system", + "OS", + "OS_ver_major", + "OS_ver_minor", + "OS_platform", + "machine_type", "graphics_card", "graphics_version" }; @@ -3976,6 +3980,10 @@ fields.FormatPush("%d",ainfo->securitylevel); fields.Push(ainfo->lastlogintime); fields.Push(ainfo->os); + fields.FormatPush("%d",ainfo->os_ver_major); + fields.FormatPush("%d",ainfo->os_ver_minor); + fields.Push(ainfo->os_platform); + fields.Push(ainfo->machine_type); fields.Push(ainfo->gfxcard); fields.Push(ainfo->gfxversion); snprintf(accountidstring,11,"%u",ainfo->accountid); Modified: trunk/src/server/database/mysql/accounts.sql =================================================================== --- trunk/src/server/database/mysql/accounts.sql 2015-02-09 20:04:54 UTC (rev 9708) +++ trunk/src/server/database/mysql/accounts.sql 2015-02-11 03:34:33 UTC (rev 9709) @@ -39,6 +39,11 @@ `realname` varchar(64) DEFAULT NULL, `advisor_ban` tinyint(1) DEFAULT '0', `operating_system` varchar(32) DEFAULT NULL, + `OS` char(1) DEFAULT NULL, + `OS_ver_major` int(2) NOT NULL DEFAULT '0', + `OS_ver_minor` int(2) NOT NULL DEFAULT '0', + `OS_platform` char(14) DEFAULT NULL, + `Machine_type` char(6) DEFAULT NULL, `graphics_card` varchar(64) DEFAULT NULL, `graphics_version` varchar(32) DEFAULT NULL, PRIMARY KEY (`id`), @@ -53,32 +58,32 @@ # #password is "keith" -INSERT INTO `accounts` VALUES (1,'vengeance','8dd9fa632ca161d0ca1929a4d99cbe77','a4e463d7dec930ea7f5a7d92fc3b798a167c7c206438739d4c82d96d5ebf2cfe','2006-06-24 00:47:50','2001-10-10 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); +INSERT INTO `accounts` VALUES (1,'vengeance','8dd9fa632ca161d0ca1929a4d99cbe77','a4e463d7dec930ea7f5a7d92fc3b798a167c7c206438739d4c82d96d5ebf2cfe','2006-06-24 00:47:50','2001-10-10 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', ''); #password is "guest" -INSERT INTO `accounts` VALUES (3,'guest','084e0343a0486ff05530df6c705c8bb4','84983c60f7daadc1cb8698621f802c0d9f9a3c3c295c810748fb048115c186ec','2003-07-22 00:31:36','2001-10-10 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); +INSERT INTO `accounts` VALUES (3,'guest','084e0343a0486ff05530df6c705c8bb4','84983c60f7daadc1cb8698621f802c0d9f9a3c3c295c810748fb048115c186ec','2003-07-22 00:31:36','2001-10-10 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); #password is "andrew" -INSERT INTO `accounts` VALUES (5,'acraig','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2001-11-11 00:00:00','0000-00-00 00:00:00','',0,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); +INSERT INTO `accounts` VALUES (5,'acraig','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2001-11-11 00:00:00','0000-00-00 00:00:00','',0,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); -INSERT INTO `accounts` VALUES (9,'superclient','e1047916967c28e68172ef5bfe31ed407b5a6d568def7cb74018704ea25da522','0','2003-07-17 14:46:08','2001-11-11 00:00:00','127.0.0.1',99,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); -INSERT INTO `accounts` VALUES (10,'superclient2','5f4dcc3b5aa765d61d8327deb882cf99','0',NULL,NULL,NULL,99,NULL,NULL,'N',0,NULL,0,0,NULL,NULL,0, '', '', ''); +INSERT INTO `accounts` VALUES (9,'superclient','e1047916967c28e68172ef5bfe31ed407b5a6d568def7cb74018704ea25da522','0','2003-07-17 14:46:08','2001-11-11 00:00:00','127.0.0.1',99,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); +INSERT INTO `accounts` VALUES (10,'superclient2','5f4dcc3b5aa765d61d8327deb882cf99','0',NULL,NULL,NULL,99,NULL,NULL,'N',0,NULL,0,0,NULL,NULL,0, '', '', 0, 0, '', '', '', '' ); #password is "andrew" for all the following accounts -INSERT INTO `accounts` VALUES (11,'dev1','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); -INSERT INTO `accounts` VALUES (12,'dev2','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); +INSERT INTO `accounts` VALUES (11,'dev1','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); +INSERT INTO `accounts` VALUES (12,'dev2','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',30,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); -INSERT INTO `accounts` VALUES (13,'gm1','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',22,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); -INSERT INTO `accounts` VALUES (14,'gm2','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',26,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); +INSERT INTO `accounts` VALUES (13,'gm1','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',22,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); +INSERT INTO `accounts` VALUES (14,'gm2','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',26,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); -INSERT INTO `accounts` VALUES (15,'player1','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); -INSERT INTO `accounts` VALUES (16,'player2','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); -INSERT INTO `accounts` VALUES (17,'player3','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); -INSERT INTO `accounts` VALUES (18,'player4','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); +INSERT INTO `accounts` VALUES (15,'player1','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', 0, 0, '', '', '', '', '' ); +INSERT INTO `accounts` VALUES (16,'player2','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', 0, 0, '', '', '', '', '' ); +INSERT INTO `accounts` VALUES (17,'player3','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', 0, 0, '', '', '', '', '' ); +INSERT INTO `accounts` VALUES (18,'player4','d914e3ecf6cc481114a3f534a5faf90b','d979885447a413abb6d606a5d0f45c3b7809e6fde2c83f0df3426f1fc9bfed97','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',0,'','US','M',1980,'A',0,0,'none','',0, '', 0, 0, '', '', '', '', '' ); #password is "planeshift" for all the following accounts -INSERT INTO `accounts` VALUES (19,'admin1','b30ee7d55aa2808cc143418fc1b93b46','4ab82ef332d3f38848c71ae8e6e10a40c0c428cfc70644e3d51ee47b89a2e5e7','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',50,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); -INSERT INTO `accounts` VALUES (20,'admin2','b30ee7d55aa2808cc143418fc1b93b46','4ab82ef332d3f38848c71ae8e6e10a40c0c428cfc70644e3d51ee47b89a2e5e7','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',50,'','US','M',1980,'A',0,0,'none','',0, '', '', ''); +INSERT INTO `accounts` VALUES (19,'admin1','b30ee7d55aa2808cc143418fc1b93b46','4ab82ef332d3f38848c71ae8e6e10a40c0c428cfc70644e3d51ee47b89a2e5e7','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',50,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); +INSERT INTO `accounts` VALUES (20,'admin2','b30ee7d55aa2808cc143418fc1b93b46','4ab82ef332d3f38848c71ae8e6e10a40c0c428cfc70644e3d51ee47b89a2e5e7','2006-06-24 00:47:50','0000-00-00 00:00:00','127.0.0.1',50,'','US','M',1980,'A',0,0,'none','',0, '', '', 0, 0, '', '', '', '' ); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2015-02-22 00:58:51
|
Revision: 9713 http://sourceforge.net/p/planeshift/code/9713 Author: ralphcampbell Date: 2015-02-22 00:58:44 +0000 (Sun, 22 Feb 2015) Log Message: ----------- Fix typo for entites Modified Paths: -------------- trunk/src/common/paws/pawslistbox.cpp trunk/src/server/command.cpp Modified: trunk/src/common/paws/pawslistbox.cpp =================================================================== --- trunk/src/common/paws/pawslistbox.cpp 2015-02-22 00:55:31 UTC (rev 9712) +++ trunk/src/common/paws/pawslistbox.cpp 2015-02-22 00:58:44 UTC (rev 9713) @@ -1325,7 +1325,7 @@ skillList->MoveRow(1,0); skillList->MoveRow(0,1); - printf("Testing with 1 and 2 entites\n"); + printf("Testing with 1 and 2 entities\n"); skillList->NewRow(); skillList->MoveRow(1,0); skillList->MoveRow(0,1); Modified: trunk/src/server/command.cpp =================================================================== --- trunk/src/server/command.cpp 2015-02-22 00:55:31 UTC (rev 9712) +++ trunk/src/server/command.cpp 2015-02-22 00:58:44 UTC (rev 9713) @@ -2601,7 +2601,7 @@ // various commands { "-- Various commands", true, NULL, "------------------------------------------------" }, - { "list", true, com_list, "List entites ( list [char|ent|path|waypoint] <filter> )" }, + { "list", true, com_list, "List entities ( list [char|ent|path|waypoint] <filter> )" }, { "entlist", true, com_entlist, "List all known entities" }, { "factions", true, com_factions, "Display factions" }, { "filtermsg", true, com_filtermsg, "Add or remove messages from the LOG_MESSAGE log"}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ral...@us...> - 2015-03-08 03:21:34
|
Revision: 9728 http://sourceforge.net/p/planeshift/code/9728 Author: ralphcampbell Date: 2015-03-08 03:21:32 +0000 (Sun, 08 Mar 2015) Log Message: ----------- Since iObjectRegistry is the top level object and is destroyed by csInitializer::DestroyApplication(), we do not need to keep csRef's to it. Modified Paths: -------------- trunk/src/client/pscelclient.h trunk/src/client/psengine.h trunk/src/common/engine/linmove.h trunk/src/common/engine/solid.h trunk/src/common/rpgrules/test/testrpgrules.h trunk/src/npcclient/npcmesh.h trunk/src/plugins/common/recast/celhpf.h trunk/src/plugins/common/recast/celnavmesh.h trunk/src/plugins/common/soundmanager/pssoundsector.h trunk/src/plugins/common/soundmanager/sectormngr.h trunk/src/plugins/common/soundmanager/soundmanager.h trunk/src/server/gemmesh.h trunk/src/tools/ccheck/ccheck.h trunk/src/tools/navgen/navgen.h trunk/src/tools/transtool/transtool.h Modified: trunk/src/client/pscelclient.h =================================================================== --- trunk/src/client/pscelclient.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/client/pscelclient.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -106,7 +106,7 @@ class psCelClient : public psClientNetSubscriber { private: - csRef<iObjectRegistry> object_reg; + iObjectRegistry* object_reg; csPDelArray<GEMClientObject> entities; csHash<GEMClientObject*, EID> entities_hash; csRefArray<MsgEntry> newActorQueue; Modified: trunk/src/client/psengine.h =================================================================== --- trunk/src/client/psengine.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/client/psengine.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -647,7 +647,7 @@ void FrameLimit(); /* plugins we're using... */ - csRef<iObjectRegistry> object_reg; ///< The Object Registry + iObjectRegistry* object_reg; ///< The Object Registry csRef<iEventNameRegistry> nameRegistry; ///< The name registry. csRef<iEngine> engine; ///< Engine plug-in handle. csRef<iConfigManager> cfgmgr; ///< Config Manager Modified: trunk/src/common/engine/linmove.h =================================================================== --- trunk/src/common/engine/linmove.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/common/engine/linmove.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -269,7 +269,7 @@ static csCollisionPair our_cd_contact[1000]; static int num_our_cd; - csRef<iObjectRegistry> object_reg; + iObjectRegistry* object_reg; csRef<iMeshWrapper> mesh; psCollisionDetection* colldet; Modified: trunk/src/common/engine/solid.h =================================================================== --- trunk/src/common/engine/solid.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/common/engine/solid.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -71,7 +71,7 @@ iCollider* GetCollider(); private: - csRef<iObjectRegistry> objectReg; ///< Needed to create the collider wrapper. + iObjectRegistry* objectReg; ///< Needed to create the collider wrapper. csWeakRef<iMeshWrapper> mesh; ///< The mesh we are using to collide with. csRef<csColliderWrapper> colliderWrap; ///< The actual collider wrapper. Modified: trunk/src/common/rpgrules/test/testrpgrules.h =================================================================== --- trunk/src/common/rpgrules/test/testrpgrules.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/common/rpgrules/test/testrpgrules.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -51,7 +51,7 @@ bool NegateMoney(iDocumentNode *command, psMoney& money); bool MultiplyMoney(iDocumentNode *command, psMoney& money); - csRef<iObjectRegistry> object_reg; + iObjectRegistry* object_reg; csRef<iVFS> vfs; csRef<iFile> log; csRef<iDocumentSystem> docsys; Modified: trunk/src/npcclient/npcmesh.h =================================================================== --- trunk/src/npcclient/npcmesh.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/npcclient/npcmesh.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -122,7 +122,7 @@ private: csRef<iMeshWrapper> mesh; ///< This is the mesh we are using. - csRef<iObjectRegistry> objectReg; ///< CS object registry list. + iObjectRegistry* objectReg; ///< CS object registry list. csWeakRef<iEngine> engine; ///< Main CS engine. psNPCClient* gem; ///< Object controller. Modified: trunk/src/plugins/common/recast/celhpf.h =================================================================== --- trunk/src/plugins/common/recast/celhpf.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/plugins/common/recast/celhpf.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -92,7 +92,7 @@ class celHNavStruct : public scfImplementation1<celHNavStruct, iCelHNavStruct> { private: - csRef<iObjectRegistry> objectRegistry; + iObjectRegistry* objectRegistry; csRef<iCelNavMeshParams> parameters; csHash<csRef<iCelNavMesh>, csPtrKey<iSector> > navMeshes; csRef<iCelGraph> hlGraph; // High level graph @@ -134,7 +134,7 @@ class celHNavStructBuilder : public scfImplementation2<celHNavStructBuilder, iCelHNavStructBuilder, iComponent> { private: - csRef<iObjectRegistry> objectRegistry; + iObjectRegistry* objectRegistry; csRef<iCelNavMeshParams> parameters; csRefArray<iSector> sectors; csHash<csRef<iCelNavMeshBuilder>, csPtrKey<iSector> > builders; Modified: trunk/src/plugins/common/recast/celnavmesh.h =================================================================== --- trunk/src/plugins/common/recast/celnavmesh.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/plugins/common/recast/celnavmesh.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -255,7 +255,7 @@ }; csRef<iSector> sector; - csRef<iObjectRegistry> objectRegistry; + iObjectRegistry* objectRegistry; csRef<iCelNavMeshPath> path; dtQueryFilter filter; dtNavMesh* detourNavMesh; @@ -310,7 +310,7 @@ { private: // Crystal space & CEL - csRef<iObjectRegistry> objectRegistry; + iObjectRegistry* objectRegistry; csRef<iSector> currentSector; csRef<iStringSet> strings; Modified: trunk/src/plugins/common/soundmanager/pssoundsector.h =================================================================== --- trunk/src/plugins/common/soundmanager/pssoundsector.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/plugins/common/soundmanager/pssoundsector.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -164,7 +164,7 @@ void Delete(); private: - csRef<iObjectRegistry> objectReg; + iObjectRegistry* objectReg; /** * Helper function that retrieve the entity associated to a mesh. It checks Modified: trunk/src/plugins/common/soundmanager/sectormngr.h =================================================================== --- trunk/src/plugins/common/soundmanager/sectormngr.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/plugins/common/soundmanager/sectormngr.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -213,7 +213,7 @@ virtual void OnSoundChange(SoundControl* sndCtrl); private: - csRef<iObjectRegistry> objectReg; ///< object registry. + iObjectRegistry* objectReg; ///< object registry. int weather; ///< current weather state (from weather.h). int timeOfDay; ///< time of the day. Modified: trunk/src/plugins/common/soundmanager/soundmanager.h =================================================================== --- trunk/src/plugins/common/soundmanager/soundmanager.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/plugins/common/soundmanager/soundmanager.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -123,7 +123,7 @@ private: - csRef<iObjectRegistry> objectReg; ///< object registry + iObjectRegistry* objectReg; ///< object registry SoundSystemManager* sndSysMgr; ///< the sound system manager used to play sounds InstrumentManager* instrMgr; ///< the instruments manager SoundSectorManager* sectorMgr; ///< the sound sectors manager. Modified: trunk/src/server/gemmesh.h =================================================================== --- trunk/src/server/gemmesh.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/server/gemmesh.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -122,7 +122,7 @@ private: csRef<iMeshWrapper> mesh; ///< This is the mesh we are using. - csRef<iObjectRegistry> objectReg; ///< CS object registry list. + iObjectRegistry* objectReg; ///< CS object registry list. csWeakRef<iEngine> engine; ///< Main CS engine. GEMSupervisor* gem; ///< Object controller. Modified: trunk/src/tools/ccheck/ccheck.h =================================================================== --- trunk/src/tools/ccheck/ccheck.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/tools/ccheck/ccheck.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -30,7 +30,7 @@ void ParseFile(const char* filePath, const char* fileName, bool processing); void PrintOutput(const char* string, ...); - csRef<iObjectRegistry> object_reg; + iObjectRegistry* object_reg; csRef<iVFS> vfs; csRef<iDocumentSystem> docsys; csRef<iStringSet> strings; Modified: trunk/src/tools/navgen/navgen.h =================================================================== --- trunk/src/tools/navgen/navgen.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/tools/navgen/navgen.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -40,6 +40,6 @@ csRef<iEngine> engine; csRef<iCelHNavStructBuilder> builder; csRef<iConfigManager> config; - csRef<iObjectRegistry> object_reg; + iObjectRegistry* object_reg; }; Modified: trunk/src/tools/transtool/transtool.h =================================================================== --- trunk/src/tools/transtool/transtool.h 2015-03-08 01:59:06 UTC (rev 9727) +++ trunk/src/tools/transtool/transtool.h 2015-03-08 03:21:32 UTC (rev 9728) @@ -28,7 +28,7 @@ private: void PrintHelp(); - csRef<iObjectRegistry> object_reg; + iObjectRegistry* object_reg; csRef<iVFS> vfs; csRef<iDocumentSystem> docsys; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rav...@us...> - 2016-04-15 16:18:28
|
Revision: 9897 http://sourceforge.net/p/planeshift/code/9897 Author: ravna-ps Date: 2016-04-15 16:18:26 +0000 (Fri, 15 Apr 2016) Log Message: ----------- Animations from SC NPC Types are now handled properly (example: <wait duration="10" anim="attack" /> ) Added an Animation command to the npc client. Added the Animation command to the NPC client -> server communication. Added processing of Animation command from NPC client to the server and set up forwarding to nearby clients. Bumped NPC net version. Modified Paths: -------------- trunk/src/common/net/messages.h trunk/src/common/net/npcmessages.h trunk/src/npcclient/networkmgr.cpp trunk/src/npcclient/networkmgr.h trunk/src/npcclient/npcoperations.cpp trunk/src/npcclient/npcoperations.h trunk/src/server/npcmanager.cpp trunk/src/server/usermanager.cpp trunk/src/server/usermanager.h Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/common/net/messages.h 2016-04-15 16:18:26 UTC (rev 9897) @@ -56,7 +56,7 @@ // NPC Networking version is separate so we don't have to break compatibility // with clients to enhance the superclients. Made it a large number to ensure // no inadvertent overlaps. -#define PS_NPCNETVERSION 0x1034 +#define PS_NPCNETVERSION 0x1035 enum Slot_Containers { Modified: trunk/src/common/net/npcmessages.h =================================================================== --- trunk/src/common/net/npcmessages.h 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/common/net/npcmessages.h 2016-04-15 16:18:26 UTC (rev 9897) @@ -220,6 +220,7 @@ CMD_DRDATA, CMD_DROP, CMD_EMOTE, + CMD_ANIMATION, CMD_EQUIP, CMD_TEMPORARILY_IMPERVIOUS, CMD_INFO_REPLY, Modified: trunk/src/npcclient/networkmgr.cpp =================================================================== --- trunk/src/npcclient/networkmgr.cpp 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/npcclient/networkmgr.cpp 2016-04-15 16:18:26 UTC (rev 9897) @@ -2268,7 +2268,23 @@ cmd_count++; } +void NetworkManager::QueueAnimationCommand(gemNPCActor* npc, const csString &cmd) +{ + CheckCommandsOverrun(100); + outbound->msg->Add((int8_t)psNPCCommandsMessage::CMD_ANIMATION); + outbound->msg->Add(npc->GetEID().Unbox()); + outbound->msg->Add(cmd); + + if (outbound->msg->overrun) + { + CS_ASSERT(!"NetworkManager::QueueEmoteCommand put message in overrun state!\n"); + } + + cmd_count++; +} + + void NetworkManager::QueueEquipCommand(gemNPCActor* entity, csString item, csString slot, int count) { CheckCommandsOverrun(100); Modified: trunk/src/npcclient/networkmgr.h =================================================================== --- trunk/src/npcclient/networkmgr.h 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/npcclient/networkmgr.h 2016-04-15 16:18:26 UTC (rev 9897) @@ -385,6 +385,14 @@ void QueueEmoteCommand(gemNPCActor* npc, gemNPCObject* target, const csString &cmd); /** + * Send an animation command to server + * + * @param npc The npc that has an animation + * @param cmd The animation + */ + void QueueAnimationCommand(gemNPCActor* npc, const csString &cmd); + + /** * Send a command to equip an equipment. */ void QueueEquipCommand(gemNPCActor* entity, csString item, csString slot, int count); Modified: trunk/src/npcclient/npcoperations.cpp =================================================================== --- trunk/src/npcclient/npcoperations.cpp 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/npcclient/npcoperations.cpp 2016-04-15 16:18:26 UTC (rev 9897) @@ -573,7 +573,17 @@ void ScriptOperation::SetAnimation(NPC* npc, const char* name) { - //npc->GetActor()->pcmesh->SetAnimation(name, false); + if (!npc) + { + Error1("SetAnimation called without a proper NPC."); + return; + } + if (!name) + { + return; + } + // send the animation command directly to the server (npc client does not have a screen anyway). + npcclient->GetNetworkMgr()->QueueAnimationCommand(npc->GetActor(), name); } void ScriptOperation::Failure(NPC* npc) Modified: trunk/src/npcclient/npcoperations.h =================================================================== --- trunk/src/npcclient/npcoperations.h 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/npcclient/npcoperations.h 2016-04-15 16:18:26 UTC (rev 9897) @@ -262,6 +262,10 @@ * */ void AddRandomRange(csVector3 &dest, float radius, float margin = 0.0); + + /** + * This function will set an animation for the NPC, the animation will play once. + */ void SetAnimation(NPC* npc, const char* name); virtual const char* GetName() const Modified: trunk/src/server/npcmanager.cpp =================================================================== --- trunk/src/server/npcmanager.cpp 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/server/npcmanager.cpp 2016-04-15 16:18:26 UTC (rev 9897) @@ -1532,6 +1532,38 @@ break; } + case psNPCCommandsMessage::CMD_ANIMATION: + { + EID npcId = EID(list.msg->GetUInt32()); // NPC + csString cmd = list.msg->GetStr(); + + Debug3(LOG_SUPERCLIENT, npcId.Unbox(), "-->Got animation cmd for entity %s with %s\n", ShowID(npcId), cmd.GetData()); + + // Make sure we haven't run past the end of the buffer + if (list.msg->overrun) + { + Debug2(LOG_SUPERCLIENT, me->clientnum, "Received incomplete CMD_ANIMATION from NPC client %u.\n", me->clientnum); + break; + } + + if (!cmd) + { + Debug2(LOG_SUPERCLIENT, me->clientnum, "Received empty animation from NPC client %u.\n", me->clientnum); + break; + } + + gemNPC* npc = dynamic_cast<gemNPC*>(gemSupervisor->FindObject(npcId)); + if (npc) + { + psserver->usermanager->Animation(cmd, npc); + } + else + { + Error1("NPC Client tries to run an animation with no existing npc"); + } + + break; + } case psNPCCommandsMessage::CMD_EQUIP: { EID entity_id = EID(list.msg->GetUInt32()); Modified: trunk/src/server/usermanager.cpp =================================================================== --- trunk/src/server/usermanager.cpp 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/server/usermanager.cpp 2016-04-15 16:18:26 UTC (rev 9897) @@ -378,6 +378,26 @@ return true; } +bool UserManager::Animation(csString animation, gemActor* actor) +{ + if (!animation) + { + Error1("invalid animation"); + return false; + } + if (!actor) + { + Error1("invalid animation actor"); + return false; + } + + // send an action override message which runs the animation + // Notice that the client is responsible for finding the animation and determining if it exists at all. + psUserActionMessage msg(actor->GetClientID(), actor->GetEID(), animation, animation); + msg.Multicast(actor->GetMulticastClients(), 0, PROX_LIST_ANY_RANGE); + return true; +} + void UserManager::HandleCharDetailsRequest(MsgEntry* me,Client* client) { psCharacterDetailsRequestMessage msg(me); Modified: trunk/src/server/usermanager.h =================================================================== --- trunk/src/server/usermanager.h 2016-04-13 22:41:52 UTC (rev 9896) +++ trunk/src/server/usermanager.h 2016-04-15 16:18:26 UTC (rev 9897) @@ -225,6 +225,12 @@ void Emote(csString general, csString specific, csString animation, gemActor* actor); /** + * This function will start an animation on the actor, it will not repeat, so if you need an animation + * loop, just call it repeatedly from a script. + */ + bool UserManager::Animation(csString animation, gemActor* actor); + + /** * Handles the /mount command * @param rider The actor which is going to mount * @param mount The actor which is going to be mounted. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rav...@us...> - 2016-05-19 22:30:21
|
Revision: 9937 http://sourceforge.net/p/planeshift/code/9937 Author: ravna-ps Date: 2016-05-19 22:30:19 +0000 (Thu, 19 May 2016) Log Message: ----------- Made /logout and "return to server select after disconnect" work in debug builds. Prevented a possible crash in cmdhandler and the spell checker when logout occurs. Modified Paths: -------------- trunk/src/client/authentclient.cpp trunk/src/client/gui/chatwindow.cpp trunk/src/common/net/cmdhandler.cpp trunk/src/common/paws/pawstextbox.cpp Modified: trunk/src/client/authentclient.cpp =================================================================== --- trunk/src/client/authentclient.cpp 2016-05-19 17:52:01 UTC (rev 9936) +++ trunk/src/client/authentclient.cpp 2016-05-19 22:30:19 UTC (rev 9937) @@ -132,14 +132,9 @@ if ( psengine->GetNetManager()->IsConnected() ) { -#ifndef CS_DEBUG // Disconnect will reset a whole host of variables, including the ref to authentclient itself, we need to preserve it till we are done. csRef<psAuthenticationClient> myRef = csRef<psAuthenticationClient>(this); HandleDisconnect(me); -#else - // If debugging leave time to experiment, only drop the network. - psengine->GetNetManager()->Disconnect(); -#endif } else { Modified: trunk/src/client/gui/chatwindow.cpp =================================================================== --- trunk/src/client/gui/chatwindow.cpp 2016-05-19 17:52:01 UTC (rev 9936) +++ trunk/src/client/gui/chatwindow.cpp 2016-05-19 22:30:19 UTC (rev 9937) @@ -2311,23 +2311,29 @@ } - const char* errorMessage = cmdsource->Publish(textToSend); - if (textToSend.StartsWith("/logout")) // in case of logout, we are already gone, to continue is to invite null pointers. - return; - if (errorMessage) - ChatOutput(errorMessage); + if (!textToSend.StartsWith("/logout")) // in case of logout, this object gets deleted, to continue is to invite null pointers. So it needs to be last. + { + const char* errorMessage = cmdsource->Publish(textToSend); - // Insert the command into the history - chatHistory->Insert(textToSend); + if (errorMessage) + ChatOutput(errorMessage); - // Now special handling for showing /tellnpc commands locally, since these are not reflected to the client from the server anymore - if (textToSend.StartsWith("/tellnpc")) + // Insert the command into the history + chatHistory->Insert(textToSend); + + // Now special handling for showing /tellnpc commands locally, since these are not reflected to the client from the server anymore + if (textToSend.StartsWith("/tellnpc")) + { + textToSend.Insert(8, "internal"); + cmdsource->Publish(textToSend); + } + + currLine.Free(); // Set to NULL + } + else { - textToSend.Insert(8,"internal"); cmdsource->Publish(textToSend); } - - currLine.Free(); // Set to NULL } } Modified: trunk/src/common/net/cmdhandler.cpp =================================================================== --- trunk/src/common/net/cmdhandler.cpp 2016-05-19 17:52:01 UTC (rev 9936) +++ trunk/src/common/net/cmdhandler.cpp 2016-05-19 22:30:19 UTC (rev 9937) @@ -124,6 +124,10 @@ if(subscribers[x]->cmd == command) { found = true; + if (command == "/logout") + { + return subscribers[x]->subscriber->HandleCommand(fullLine); // the return value is BS, but it does stop the execution. :) + } const char* ret = subscribers[x]->subscriber->HandleCommand(fullLine); if(ret) err = ret; Modified: trunk/src/common/paws/pawstextbox.cpp =================================================================== --- trunk/src/common/paws/pawstextbox.cpp 2016-05-19 17:52:01 UTC (rev 9936) +++ trunk/src/common/paws/pawstextbox.cpp 2016-05-19 22:30:19 UTC (rev 9937) @@ -1463,6 +1463,9 @@ parent->OnChange(this); } + // don't check spelling when we hit enter. + if (key == CSKEY_ENTER) + return pawsWidget::OnKeyDown(code, key, modifiers); if((key < 128 && !isprint(key)) || CSKEY_IS_SPECIAL(key)) pawsWidget::OnKeyDown(code, key, modifiers); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lpa...@us...> - 2017-01-29 18:38:52
|
Revision: 9992 http://sourceforge.net/p/planeshift/code/9992 Author: lpancallo Date: 2017-01-29 18:38:49 +0000 (Sun, 29 Jan 2017) Log Message: ----------- Added more documentation of classes. Modified Paths: -------------- trunk/src/common/net/clientmsghandler.h trunk/src/common/paws/pawskeyselectbox.h trunk/src/common/paws/widgetconfigwindow.h trunk/src/npcclient/tribe.h trunk/src/server/bulkobjects/psactionlocationinfo.h trunk/src/server/bulkobjects/psattack.h trunk/src/server/bulkobjects/pscharacterlist.h trunk/src/server/bulkobjects/psglyph.h trunk/src/server/bulkobjects/psmerchantinfo.h trunk/src/server/bulkobjects/psnpcdialog.h trunk/src/server/bulkobjects/psnpcloader.h trunk/src/server/bulkobjects/psquest.h trunk/src/server/bulkobjects/psquestprereqops.h trunk/src/server/bulkobjects/psraceinfo.h trunk/src/server/bulkobjects/pssectorinfo.h trunk/src/server/bulkobjects/psskills.h trunk/src/server/bulkobjects/pstrade.h trunk/src/server/bulkobjects/pstrainerinfo.h trunk/src/server/bulkobjects/pstrait.h trunk/src/server/bulkobjects/servervitals.h Modified: trunk/src/common/net/clientmsghandler.h =================================================================== --- trunk/src/common/net/clientmsghandler.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/common/net/clientmsghandler.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -32,6 +32,9 @@ * \addtogroup common_net * @{ */ +/** + * Handles messages to be sent out, connects to server and send those + */ class ClientMsgHandler : public MsgHandler { public: Modified: trunk/src/common/paws/pawskeyselectbox.h =================================================================== --- trunk/src/common/paws/pawskeyselectbox.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/common/paws/pawskeyselectbox.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -27,7 +27,7 @@ * @{ */ /** - * A widget that can be used to select key and display combinations. + * A widget that can be used to get a key combination (alt+a, ctrl+s) and display it in text format. */ class pawsKeySelectBox : public pawsWidget { Modified: trunk/src/common/paws/widgetconfigwindow.h =================================================================== --- trunk/src/common/paws/widgetconfigwindow.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/common/paws/widgetconfigwindow.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -34,9 +34,9 @@ * \addtogroup common_paws * @{ */ -//----------------------------------------------------------------------------- -// class WidgetConfigWindow -//----------------------------------------------------------------------------- +/** + * Shown when you right click on a window. Sets alpha trasparency, fade speed, font scaling + */ class WidgetConfigWindow : public pawsWidget { public: Modified: trunk/src/npcclient/tribe.h =================================================================== --- trunk/src/npcclient/tribe.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/npcclient/tribe.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -60,7 +60,9 @@ #define TRIBE_UNLIMITED_SIZE 100 /** - * Class used to define a Tribal Object + * Holds list of tribe members, position of tribe home + * Keeps resources and handles tribe perceptions. + * */ class Tribe : public ScopedTimerCB, public RemoteDebug { Modified: trunk/src/server/bulkobjects/psactionlocationinfo.h =================================================================== --- trunk/src/server/bulkobjects/psactionlocationinfo.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psactionlocationinfo.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -52,10 +52,8 @@ * @{ */ /** - * This huge class stores all the properties of any object - * a player can have in the game. All stats, bonuses, maluses, - * magic stat alterations, combat properties, spell effects, - * and so forth are all stored here. + * This class stores all the properties of an action location + * Entrance, return location, name, response type, trigger. */ class psActionLocation { Modified: trunk/src/server/bulkobjects/psattack.h =================================================================== --- trunk/src/server/bulkobjects/psattack.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psattack.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -53,7 +53,7 @@ struct Stance; class psCombatAttackGameEvent; -/** This stuct holds data for generic attack types +/** This struct holds data for generic attack types * This could be for example an assassin attack which would require maybe daggers. and require dual wielded daggers at that, so each dagger does part of the attack specifically. * each attack type would also be based off a specic skill, such as strength or agility. */ Modified: trunk/src/server/bulkobjects/pscharacterlist.h =================================================================== --- trunk/src/server/bulkobjects/pscharacterlist.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/pscharacterlist.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -36,6 +36,10 @@ #define MAX_CHARACTERS_IN_LIST 10 +/** + * Holds a list of characters associated to one account. + * Used in the select character screen. + */ class psCharacterList : public iCachedObject { public: Modified: trunk/src/server/bulkobjects/psglyph.h =================================================================== --- trunk/src/server/bulkobjects/psglyph.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psglyph.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -44,6 +44,8 @@ /** + * Defines a glyph, one element to create a spell. + * Loads definition from database, manages purify status. */ class psGlyph : public psItem { Modified: trunk/src/server/bulkobjects/psmerchantinfo.h =================================================================== --- trunk/src/server/bulkobjects/psmerchantinfo.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psmerchantinfo.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -51,13 +51,16 @@ }; - +/** + * This class retrieves the merchant categories for an NPC. + * A character is defined to be a merchant if there are + * merchant item categories for the character. + */ class psMerchantInfo : public csRefCount { public: /** - * A character is defined to be a merchant if there are - * merchant item categories for the character. + * Loads the merchant categories for one NPC * * @param pid The characterid to check. * @return Return true if the character is a merchant. Modified: trunk/src/server/bulkobjects/psnpcdialog.h =================================================================== --- trunk/src/server/bulkobjects/psnpcdialog.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psnpcdialog.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -51,6 +51,11 @@ struct iObjectRegistry; +/** + * A KnowledgeArea is a set of triggers and answers the NPC can provide when asked. + * Example can be knowledgearea of a city, famous personalities or a job. + * Knowledge areas have priorities to define which one is searched first for an answer. + */ struct KnowledgeArea { csString area; Modified: trunk/src/server/bulkobjects/psnpcloader.h =================================================================== --- trunk/src/server/bulkobjects/psnpcloader.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psnpcloader.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -42,6 +42,10 @@ class psDialogManager; struct psTrainerSkill; +/** + * This is a utility class used to load/save NPCs from/to an XML file + * Was used in the past to load NPCs created by people with no access to the database or webconsole. + */ class psNPCLoader { public: Modified: trunk/src/server/bulkobjects/psquest.h =================================================================== --- trunk/src/server/bulkobjects/psquest.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psquest.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -61,7 +61,8 @@ bool LoadPrerequisiteXML(csRef<psQuestPrereqOp> &prerequisite, psQuest* self, csString script); /** - * This class holds the master list of all quests available in the game. + * This class holds all information for one quest with its reference to parent quest, list of steps, + * lockoutime, sub quests, ... */ class psQuest : public CS::Utility::WeakReferenced { Modified: trunk/src/server/bulkobjects/psquestprereqops.h =================================================================== --- trunk/src/server/bulkobjects/psquestprereqops.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psquestprereqops.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * + * Contains all prerequisites for a quest to be active, example completion of another quest, + * or certain skills/ranks */ #ifndef __PSQUESTPREREQOPS_H__ Modified: trunk/src/server/bulkobjects/psraceinfo.h =================================================================== --- trunk/src/server/bulkobjects/psraceinfo.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psraceinfo.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -51,6 +51,10 @@ const char* sector_name; }; +/** + * Defines characteristics of a race associated to an NPC, player or pet. + * Includes gender, movement speed, armor, items, regeneration, ... + */ struct psRaceInfo { protected: Modified: trunk/src/server/bulkobjects/pssectorinfo.h =================================================================== --- trunk/src/server/bulkobjects/pssectorinfo.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/pssectorinfo.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -39,14 +39,10 @@ //============================================================================= -/** Contains information about sectors from the server perspective. -* -* Right now this class just includes the ID, name of a sector and rain parameters. -* Future versions may include parameters for a bounding box, portals to other sectors, or other information. -* -* -* -*/ +/** + * Contains information about sectors from the server perspective. + * It includes the ID, name of a sector and weather parameters. + */ class psSectorInfo : public iScriptableVar { public: Modified: trunk/src/server/bulkobjects/psskills.h =================================================================== --- trunk/src/server/bulkobjects/psskills.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/psskills.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -65,6 +65,10 @@ PSSKILLS_CATEGORY_FACTIONS }; +/** + * Represents a skill an NPC, player or pet can learn. + * Includes description, cost, practice needed + */ class psSkillInfo { public: Modified: trunk/src/server/bulkobjects/pstrade.h =================================================================== --- trunk/src/server/bulkobjects/pstrade.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/pstrade.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * Defines crafting transformations, combinations, processes and patterns. */ #ifndef __PSTRADE_H__ Modified: trunk/src/server/bulkobjects/pstrainerinfo.h =================================================================== --- trunk/src/server/bulkobjects/pstrainerinfo.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/pstrainerinfo.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -44,7 +44,9 @@ float min_faction; }; - +/** + * Holds information about the skills a character (usually NPC) can teach. + */ class psTrainerInfo : public csRefCount { public: Modified: trunk/src/server/bulkobjects/pstrait.h =================================================================== --- trunk/src/server/bulkobjects/pstrait.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/pstrait.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -34,6 +34,10 @@ // Local Includes //============================================================================= +/** + * Represent a visual feature of character customization + * like hair style, color of eyes, skin color, ... + */ struct psTrait { psTrait(); Modified: trunk/src/server/bulkobjects/servervitals.h =================================================================== --- trunk/src/server/bulkobjects/servervitals.h 2017-01-21 22:00:55 UTC (rev 9991) +++ trunk/src/server/bulkobjects/servervitals.h 2017-01-29 18:38:49 UTC (rev 9992) @@ -73,10 +73,11 @@ //---------------------------------------------------------------------------- -/** Server side of the character vitals manager. Does a lot more accessing - * of the data to set particular things. Also does construction of data to - * send to a client. - */ +/** + * Server side of the character vitals manager. Does a lot more accessing + * of the data to set particular things. Also does construction of data to + * send to a client. + */ class psServerVitals : public psVitalManager<Vital> { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |