From cbbbc74a601df00d85e141dc922ee6f3cf82a488 Mon Sep 17 00:00:00 2001 From: Riasan Date: Tue, 15 Dec 2020 21:40:37 +0100 Subject: [PATCH 01/11] Changed: add lua function --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 180 +++++++++++------- .../client/src/interface_v3/lua_ihm_ryzom.h | 8 +- 2 files changed, 112 insertions(+), 76 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 8aa7af585..e7cbb0ea6 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -565,6 +565,8 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(isDynStringAvailable), LUABIND_FUNC(isFullyPatched), LUABIND_FUNC(getSheetType), + LUABIND_FUNC(getSheetShape), + LUABIND_FUNC(getCharacterSheetScale), LUABIND_FUNC(getSheetFamily), LUABIND_FUNC(getSheetName), LUABIND_FUNC(getFameIndex), @@ -1245,7 +1247,7 @@ int CLuaIHMRyzom::getMousePos(CLuaState &ls) CTool::getMousePos(x, y); ls.push(x); ls.push(y); - + return 2; } @@ -1257,7 +1259,7 @@ int CLuaIHMRyzom::getMouseDown(CLuaState &ls) ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1266,11 +1268,11 @@ int CLuaIHMRyzom::getMouseMiddleDown(CLuaState &ls) sint32 x, y; bool down; CTool::getMouseMiddleDown(down, x, y); - + ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1279,11 +1281,11 @@ int CLuaIHMRyzom::getMouseRightDown(CLuaState &ls) sint32 x, y; bool down; CTool::getMouseRightDown(down, x, y); - + ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1294,10 +1296,10 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - + uint32 x = (uint32)ls.toInteger(1); - uint32 y = (uint32)ls.toInteger(2); - + uint32 y = (uint32)ls.toInteger(2); + uint32 w, h; CViewRenderer &viewRender = *CViewRenderer::getInstance(); viewRender.getScreenSize(w, h); @@ -1308,11 +1310,11 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls) float cursX = (float)x/(float)w; float cursY = (float)y/(float)h; - + sint32 instance_idx; EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx); ls.push(instance_idx); - + return 1; } @@ -1339,7 +1341,7 @@ int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls) worldViewRay.Up = camMatrix.getK().normed(); CVector sceneInter; CTool::TRayIntersectionType rayInterType = CTool::computeLandscapeRayIntersection(worldViewRay, sceneInter); - + ls.push(sceneInter.x); ls.push(sceneInter.y); ls.push(sceneInter.z); @@ -1367,7 +1369,7 @@ int CLuaIHMRyzom::moveCam(CLuaState &ls) float z = (float)ls.toNumber(3); CVector moves(x, y, z); UserEntity->setCameraMoves(moves); - + return 0; } @@ -1541,7 +1543,7 @@ int CLuaIHMRyzom::moveToTarget(CLuaState &ls) const std::string &url = ls.toString(1); CEntityCL *target = getTargetEntity(); if (!target) return 0; - + CLuaManager::getInstance().executeLuaScript("ArkTargetUrl = [["+url+"]]", 0); UserEntity->moveTo(UserEntity->selection(), 1.0, CUserEntity::OpenArkUrl); return 0; @@ -2180,7 +2182,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); sint32 idx = -1; - + if (!Scene) { nlwarning("No scene available"); @@ -2189,7 +2191,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) } string shape = ls.toString(1); - + float x = 0.0f, y = 0.0f, z = 0.0f; float scale = 1.0f; string context, url, skeleton, texture; @@ -2197,7 +2199,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) bool transparency = false; bool collision = true; bool inIgZone = false; - + if (ls.getTop() >= 2) { CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); @@ -2223,14 +2225,14 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) y = UserEntity->pos().y; z = UserEntity->pos().z; } - + CVector userDir = UserEntity->dir(); - + if (ls.getTop() >= 5) { CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); string angle = ls.toString(5); - + if (angle != "user") { float a; @@ -2238,7 +2240,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) userDir = CVector(sin(a), cos(a), 0.f); } } - + if (ls.getTop() >= 6) { CLuaIHM::checkArgType(ls, funcName, 6, LUA_TNUMBER); @@ -2250,19 +2252,19 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 7, LUA_TBOOLEAN); collision = ls.toBoolean(7); } - + if (ls.getTop() >= 8) { CLuaIHM::checkArgType(ls, funcName, 8, LUA_TSTRING); context = ls.toString(8); } - + if (ls.getTop() >= 9) { CLuaIHM::checkArgType(ls, funcName, 9, LUA_TSTRING); url = ls.toString(9); } - + if (ls.getTop() >= 10) { CLuaIHM::checkArgType(ls, funcName, 10, LUA_TBOOLEAN); @@ -2274,25 +2276,25 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 11, LUA_TBOOLEAN); transparency = ls.toBoolean(11); } - + if (ls.getTop() >= 12) { CLuaIHM::checkArgType(ls, funcName, 12, LUA_TSTRING); texture = ls.toString(12); } - + if (ls.getTop() >= 13) { CLuaIHM::checkArgType(ls, funcName, 13, LUA_TSTRING); skeleton = ls.toString(13); } - + if (ls.getTop() >= 14) { CLuaIHM::checkArgType(ls, funcName, 14, LUA_TBOOLEAN); inIgZone = ls.toBoolean(14); } - + CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector(x, y, z), context, url, collision, inIgZone, idx); UInstance instance = instref.Instance; @@ -2373,9 +2375,9 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) instance.setPos(CVector(x, y, z)); instance.setRotQuat(dir.getRot()); } - + instance.setTransformMode(UTransformable::RotEuler); - + // if the shape is a particle system, additionnal parameters are user params UParticleSystemInstance psi; psi.cast (instance); @@ -2398,7 +2400,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) } } }*/ - + UMovePrimitive *primitive = instref.Primitive; if (primitive) { @@ -2408,7 +2410,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) primitive->setReactionType(UMovePrimitive::Slide); primitive->setTriggerType(UMovePrimitive::NotATrigger); primitive->setAbsorbtion(0); - + primitive->setPrimitiveType(UMovePrimitive::_2DOrientedBox); primitive->setSize((bbox.getMax().x - bbox.getMin().x)*scale, (bbox.getMax().y - bbox.getMin().y)*scale); primitive->setHeight((bbox.getMax().z - bbox.getMin().z)*scale); @@ -2416,10 +2418,10 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) primitive->setCollisionMask(MaskColPlayer | MaskColNpc | MaskColDoor); primitive->setOcclusionMask(MaskColPlayer | MaskColNpc | MaskColDoor); primitive->setObstacle(true); - - + + primitive->setGlobalPosition(instance.getPos(), dynamicWI); - + primitive->insertInWorldImage(dynamicWI); } } @@ -2434,9 +2436,9 @@ int CLuaIHMRyzom::setupShape(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE); - + uint32 idx = (uint32)ls.toInteger(1); - + std::vector keys; std::vector values; CLuaObject params; @@ -2459,12 +2461,12 @@ int CLuaIHMRyzom::setupShape(CLuaState &ls) values.push_back(it.nextValue().toString()); keys.push_back(it.nextKey().toString()); } - + if (EntitiesMngr.setupInstance(idx, keys, values)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2476,15 +2478,15 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstancePos(idx); string x = ls.toString(2); string y = ls.toString(3); string z = ls.toString(4); - + float move_x = 0; float move_y = 0; float move_z = 0; @@ -2502,7 +2504,7 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.x = move_x; } } - + if (!y.empty()) { if (y[0] == '+') @@ -2516,7 +2518,7 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.y = move_y; } } - + if (!z.empty()) { if (z[0] == '+') @@ -2530,12 +2532,12 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.z = move_z; } } - + if (EntitiesMngr.setInstancePos(idx, pos)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2547,9 +2549,9 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector rot = EntitiesMngr.getInstanceRot(idx); string x = ls.toString(2); @@ -2573,7 +2575,7 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.x = rot_x; } } - + if (!y.empty()) { if (y[0] == '+') @@ -2587,7 +2589,7 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.y = rot_y; } } - + if (!z.empty()) { if (z[0] == '+') @@ -2601,12 +2603,12 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.z = rot_z; } } - + if (EntitiesMngr.setInstanceRot(idx, rot)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2615,7 +2617,7 @@ int CLuaIHMRyzom::deleteShape(CLuaState &ls) const char* funcName = "deleteShape"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + if (EntitiesMngr.deleteInstance((uint32)ls.toInteger(1))) ls.push(1); else @@ -2629,9 +2631,9 @@ int CLuaIHMRyzom::getShapePos(CLuaState &ls) const char* funcName = "getShapePos"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstancePos(idx); ls.push(pos.x); @@ -2645,9 +2647,9 @@ int CLuaIHMRyzom::getShapeRot(CLuaState &ls) const char* funcName = "getShapeRot"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector rot = EntitiesMngr.getInstanceRot(idx); ls.push(rot.x); @@ -2661,11 +2663,11 @@ int CLuaIHMRyzom::getShapeScale(CLuaState &ls) const char* funcName = "getShapeScale"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector scale = EntitiesMngr.getInstanceScale(idx); - + ls.push(scale.x); ls.push(scale.y); ls.push(scale.z); @@ -2677,11 +2679,11 @@ int CLuaIHMRyzom::getShapeColPos(CLuaState &ls) const char* funcName = "getShapeColPos"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstanceColPos(idx); - + ls.push(pos.x); ls.push(pos.y); ls.push(pos.z); @@ -2693,11 +2695,11 @@ int CLuaIHMRyzom::getShapeColScale(CLuaState &ls) const char* funcName = "getShapeColScale"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector scale = EntitiesMngr.getInstanceColScale(idx); - + ls.push(scale.x); ls.push(scale.y); ls.push(scale.z); @@ -2709,11 +2711,11 @@ int CLuaIHMRyzom::getShapeColOrient(CLuaState &ls) const char* funcName = "getShapeColOrient"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + double orient = EntitiesMngr.getInstanceColOrient(idx); - + ls.push(orient); return 1; } @@ -3469,6 +3471,38 @@ std::string CLuaIHMRyzom::getSheetType(const std::string &sheet) return CEntitySheet::typeToString(sheetPtr->Type); } +// *************************************************************************** +std::string CLuaIHMRyzom::getSheetShape(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_getSheetType) + const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); + + if (!sheetPtr) + return ""; + + if (sheetPtr->type() == CEntitySheet::ITEM) + { + CItemSheet *sheet = (CItemSheet*)sheetPtr; + return sheet->getShape(); + } + else if (sheetPtr->type() == CEntitySheet::FAUNA) + { + CCharacterSheet *sheet = (CCharacterSheet*)(sheetPtr); + return sheet->Body.getItem(); + } + + return ""; +} + +// *************************************************************************** +float CLuaIHMRyzom::getCharacterSheetScale(const std::string &sheet) +{ + const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); + const CCharacterSheet *charSheet = dynamic_cast(sheetPtr); + + if (charSheet) return charSheet->Scale; + return 1; +} // *************************************************************************** std::string CLuaIHMRyzom::getSheetFamily(const std::string &sheet) @@ -3481,7 +3515,7 @@ std::string CLuaIHMRyzom::getSheetFamily(const std::string &sheet) if (pIS) return ITEMFAMILY::toString(pIS->Family); } - + return ""; } @@ -3712,7 +3746,7 @@ float CLuaIHMRyzom::setChar3dDBfromVPX(const std::string &branch, const std::str cs.People = EGSPD::CPeople::fromString(people); SCharacter3DSetup::setupDBFromCharacterSummary(branch, cs); - + return cs.VisualPropC.PropertySubData.CharacterHeight; } @@ -4172,12 +4206,12 @@ int CLuaIHMRyzom::addLandMark(CLuaState &ls) point.LeftClickParam = ls.toString(6); point.RightClickAction = ls.toString(7); point.RightClickParam = ls.toString(8); - + point.Color = CRGBA(255,255,255,255); if (ls.getTop() >= 9) CLuaIHM::pop(ls, point.Color); - + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pMap != NULL) pMap->addArkPoint(point); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 78b5a2a00..e134b00a0 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -15,7 +15,7 @@ private: static int luaClientCfgIndex(CLuaState &ls); static int luaClientCfgNewIndex(CLuaState &ls); - + // CInterfaceElement management on stack, stored by a CRefPtr. public: @@ -204,6 +204,8 @@ private: static bool isDynStringAvailable(sint32 dynStringId); static bool isFullyPatched(); static std::string getSheetType(const std::string &sheet); + static std::string getSheetShape(const std::string &sheet); + static float getCharacterSheetScale(const std::string &sheet); static std::string getSheetFamily(const std::string &sheet); static std::string getSheetName(uint32 sheetId); static sint32 getFameIndex(const std::string &factionName); @@ -251,7 +253,7 @@ private: static int addRespawnPoint(CLuaState &ls); static int delArkPoints(CLuaState &ls); static int setArkPowoOptions(CLuaState &ls); - + // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly // else, current command of the chat window will be replaced with tell 'player' @@ -260,7 +262,7 @@ private: static void updateTooltipCoords(); // test if the ctrl key is down (NB nico : I didn't add other key, // because it would be too easy to write a key recorder ...) - static bool isCtrlKeyDown(); + static bool isCtrlKeyDown(); static std::string encodeURLUnicodeParam(const ucstring &text); static std::string encodeURLParam(const std::string &text); From 9771d79bc3033af9a97f18dd15645d79f84dfa00 Mon Sep 17 00:00:00 2001 From: Nuno Date: Wed, 6 Jan 2021 19:32:42 +0100 Subject: [PATCH 02/11] Fixed bad conversion in getPlayerVp*Hex and getTargetVp*Hex --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 43 +++++++++---------- .../client/src/interface_v3/lua_ihm_ryzom.h | 12 +++--- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 68a39bb2c..75b588ce0 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -3904,40 +3904,40 @@ sint32 CLuaIHMRyzom::getPlayerLevel() // *************************************************************************** std::string CLuaIHMRyzom::getPlayerVpaHex() { - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** std::string CLuaIHMRyzom::getPlayerVpbHex() { - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** std::string CLuaIHMRyzom::getPlayerVpcHex() { - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** -sint64 CLuaIHMRyzom::getPlayerVpa() +uint64 CLuaIHMRyzom::getPlayerVpa() { uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getPlayerVpb() +uint64 CLuaIHMRyzom::getPlayerVpb() { uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getPlayerVpc() +uint64 CLuaIHMRyzom::getPlayerVpc() { uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); return prop; @@ -3989,8 +3989,8 @@ std::string CLuaIHMRyzom::getTargetVpaHex() CEntityCL *target = getTargetEntity(); if (!target) return 0; - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** @@ -3999,8 +3999,8 @@ std::string CLuaIHMRyzom::getTargetVpbHex() CEntityCL *target = getTargetEntity(); if (!target) return 0; - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** @@ -4009,40 +4009,37 @@ std::string CLuaIHMRyzom::getTargetVpcHex() CEntityCL *target = getTargetEntity(); if (!target) return 0; - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** -sint64 CLuaIHMRyzom::getTargetVpa() +uint64 CLuaIHMRyzom::getTargetVpa() { CEntityCL *target = getTargetEntity(); if (!target) return 0; uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getTargetVpb() +uint64 CLuaIHMRyzom::getTargetVpb() { CEntityCL *target = getTargetEntity(); if (!target) return 0; - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getTargetVpc() +uint64 CLuaIHMRyzom::getTargetVpc() { CEntityCL *target = getTargetEntity(); if (!target) return 0; - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); - + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); return prop; } diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 1ca8de42a..f8db32363 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -272,9 +272,9 @@ private: static std::string getPlayerVpaHex(); static std::string getPlayerVpbHex(); static std::string getPlayerVpcHex(); - static sint64 getPlayerVpa(); - static sint64 getPlayerVpb(); - static sint64 getPlayerVpc(); + static uint64 getPlayerVpa(); + static uint64 getPlayerVpb(); + static uint64 getPlayerVpc(); static sint32 getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target @@ -282,9 +282,9 @@ private: static std::string getTargetVpaHex(); static std::string getTargetVpbHex(); static std::string getTargetVpcHex(); - static sint64 getTargetVpa(); - static sint64 getTargetVpb(); - static sint64 getTargetVpc(); + static uint64 getTargetVpa(); + static uint64 getTargetVpb(); + static uint64 getTargetVpc(); static bool isTargetNPC(); // return 'true' if the target is an npc static bool isTargetPlayer(); // return 'true' if the target is a player static bool isTargetUser(); // return 'true' if the target is the user From 0a81f406065addc4cccc16ad95accf28756762a2 Mon Sep 17 00:00:00 2001 From: Riasan Date: Sun, 10 Jan 2021 19:09:48 +0100 Subject: [PATCH 03/11] Fixed: Typo --- code/ryzom/client/src/interface_v3/action_handler_game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 3e3ce9b8e..b200205be 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -4686,7 +4686,7 @@ class CHandlerOutgameNaviGetKeys : public IActionHandler id = "sel"; if (event != -1) -- CLuaManager::getInstance().executeLuaScript(toString("outgame:eventChar%sKeyGet(%i)", id.c_str(), event)); + CLuaManager::getInstance().executeLuaScript(toString("outgame:eventChar%sKeyGet(%i)", id.c_str(), event)); } // reset previous input Driver->AsyncListener.reset(); From ae9989dfe41362fc17d1b6dbad7fb01df73e1f29 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 14 Jan 2021 15:53:12 +0100 Subject: [PATCH 04/11] Updated default textures in client --- code/ryzom/client/src/client_cfg.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index df1debee2..6758d440a 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -326,8 +326,8 @@ CClientConfig::CClientConfig() Local = false; // Default is Net Mode. FSHost = ""; // Default Host. - TexturesInterface.push_back("texture_interfaces_v3"); - TexturesInterfaceDXTC.push_back("texture_interfaces_dxtc"); + TexturesInterface.push_back("texture_interfaces_v3_2x"); + TexturesInterfaceDXTC.push_back("texture_interfaces_dxtc_2x"); TexturesOutGameInterface.push_back("texture_interfaces_v3_outgame_ui"); @@ -782,8 +782,8 @@ void CClientConfig::setValues() READ_STRINGVECTOR_FV(TexturesOutGameInterfaceDXTC); // interface textures ingame and r2 - READ_STRINGVECTOR_FV(TexturesInterface); - READ_STRINGVECTOR_FV(TexturesInterfaceDXTC); + //READ_STRINGVECTOR_FV(TexturesInterface); + //READ_STRINGVECTOR_FV(TexturesInterfaceDXTC); // interface files login menus READ_STRINGVECTOR_FV(XMLLoginInterfaceFiles); From 4726e74dcd028de170f81d0117e41113065f18de Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 14 Jan 2021 16:04:54 +0100 Subject: [PATCH 05/11] Added marauder to static fames --- code/ryzom/common/src/game_share/fame.cpp | 13 +++++++++++-- code/ryzom/common/src/game_share/fame.h | 11 ++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/code/ryzom/common/src/game_share/fame.cpp b/code/ryzom/common/src/game_share/fame.cpp index cd9e2b850..19c3cbb80 100644 --- a/code/ryzom/common/src/game_share/fame.cpp +++ b/code/ryzom/common/src/game_share/fame.cpp @@ -534,7 +534,7 @@ void CStaticFames::loadTribeThreshold( const string& filename ) // check table structure uint nbTribe = ws.size()-2; nlassert(nbTribe<=_FameTableSize); - nlassert(ws.ColCount == 16); // 5 ( 4 people + neutral ) * 3 cult + 1 for tribe name + nlassert(ws.ColCount == 17); // 5 ( 4 people + neutral ) * 3 cult + 1 for tribe name + marauder _TribeCultThresholdPerCiv.resize(nbTribe); @@ -548,7 +548,7 @@ void CStaticFames::loadTribeThreshold( const string& filename ) _TribeCultThresholdPerCiv[i-2].FameIndex = index; - for( uint c=1; csetMarauder(thresholdMarauder*6000); } } } diff --git a/code/ryzom/common/src/game_share/fame.h b/code/ryzom/common/src/game_share/fame.h index fde8611b8..c0cc856bb 100644 --- a/code/ryzom/common/src/game_share/fame.h +++ b/code/ryzom/common/src/game_share/fame.h @@ -52,26 +52,30 @@ public: Kami = 0; Karavan = 0; Neutral = 0; + Marauder = 0; } void setKami(sint32 t) { Kami = t; } void setKaravan(sint32 t) { Karavan = t; } void setNeutral(sint32 t) { Neutral = t; } + void setMarauder(sint32 t) { Marauder = t; } sint32 getKami() const { return Kami; } sint32 getKaravan() const { return Karavan; } sint32 getNeutral() const { return Neutral; } + sint32 getMarauder() const { return Marauder; } private: sint32 Kami; sint32 Karavan; sint32 Neutral; + sint32 Marauder; }; class CTribeCultThresholdPerCiv { public: - bool getCultThresholdForCiv( PVP_CLAN::TPVPClan civ, sint32& kami, sint32& karavan, sint32& neutral) const + bool getCultThresholdForCiv( PVP_CLAN::TPVPClan civ, sint32& kami, sint32& karavan, sint32& neutral, sint32& marauder) const { const CTribeCultThreshold * tc = 0; switch( civ ) @@ -88,12 +92,16 @@ public: case PVP_CLAN::Neutral: tc = &Neutral; break; + case PVP_CLAN::Marauder: + tc = &Marauder; + break; default: return false; } kami = tc->getKami(); karavan = tc->getKaravan(); neutral = tc->getNeutral(); + marauder = tc->getMarauder(); return true; } @@ -103,6 +111,7 @@ public: CTribeCultThreshold Tryker; CTribeCultThreshold Zorai; CTribeCultThreshold Neutral; + CTribeCultThreshold Marauder; }; // declare scoped constant value From 951f000be4428e707eae5333305fcbbc47c341d3 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 14 Jan 2021 16:05:40 +0100 Subject: [PATCH 06/11] Keep missions window open when player accept one of them --- code/ryzom/client/src/interface_v3/bot_chat_manager.cpp | 6 ++++++ code/ryzom/client/src/interface_v3/bot_chat_manager.h | 3 +++ .../ryzom/client/src/interface_v3/bot_chat_page_mission.cpp | 1 + code/ryzom/client/src/interface_v3/bot_chat_page_mission.h | 1 + 4 files changed, 11 insertions(+) diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp index d25763bff..839381b91 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp @@ -86,6 +86,12 @@ void CBotChatManager::setCurrPage(CBotChatPage *page) UserEntity->trader(CLFECOMMON::INVALID_SLOT); } _CurrPage = page; + + if (page == NULL && !_AHAfterEnd.empty()) + { + CAHManager::getInstance()->runActionHandler(_AHAfterEnd, NULL, ""); + _AHAfterEnd = ""; + } } // ******************************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.h b/code/ryzom/client/src/interface_v3/bot_chat_manager.h index cbd2713f8..9b9f996fc 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.h +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.h @@ -93,12 +93,15 @@ public: // Called for local client debugging void debugLocalReceiveMissionInfo(); + void setAHAfterEnd(const std::string &ah) { _AHAfterEnd = ah ;} + ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// private: CBotChatPage *_CurrPage; uint16 _SessionID; + std::string _AHAfterEnd; static CBotChatManager *_Instance; //uint _ChosenMissionFlags; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index ad95a35e5..4830fb096 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -161,6 +161,7 @@ void CBotChatPageMission::acceptMission() /// close the botchat //CBotChatManager::getInstance()->setCurrPage(NULL); _CurrSel = NULL; + CBotChatManager::getInstance()->setAHAfterEnd("context_choose_mission"); } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h index 03cb8d95e..0e458fc7a 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h @@ -51,6 +51,7 @@ private: // an observer to update big mission list from littles pages in server database CHugeListObs _MissionPagesObs; CDBCtrlSheet *_CurrSel; + bool _HaveAcceptedMission; MISSION_DESC::TClientMissionType _MType; }; From 46c7b0309d0891d514c77b34e551b43374507a41 Mon Sep 17 00:00:00 2001 From: Nuno Date: Tue, 19 Jan 2021 19:34:20 +0100 Subject: [PATCH 07/11] Added icons to broadcast --- .../interface_v3/group_in_scene_bubble.cpp | 33 +++++++++++++++++-- .../src/interface_v3/interface_manager.cpp | 19 ++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 2276eb506..015800173 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -28,6 +28,7 @@ #include "nel/gui/action_handler.h" #include "../entities.h" #include "nel/gui/group_paragraph.h" // For CCtrlLink +#include "nel/gui/view_bitmap.h" #include "../net_manager.h" #include "../string_manager_client.h" #include "../login.h" @@ -644,14 +645,42 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, "ui:interface", templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); if (group) { + ucstring finalMessage = message; + + ucstring::size_type pos = message.find(ucstring("|")); + if (pos != std::string::npos) + { + CViewBitmap *pViewIcon = dynamic_cast(group->getView("iconA")); + if (pViewIcon != NULL) + { + string texture = message.substr(0, pos).toString(); + pViewIcon->setTexture(texture); + } + + ucstring::size_type end = message.find(ucstring("|"), pos+1); + if (end != std::string::npos) + { + CViewBitmap *pViewIcon = dynamic_cast(group->getView("iconZ")); + if (pViewIcon != NULL) + { + string texture = message.substr(end+1).toString(); + pViewIcon->setTexture(texture); + } + finalMessage = message.substr(pos+1, end-pos-1); + } + else + finalMessage = message.substr(pos+1); + } + // Skill name CViewText *pViewName = dynamic_cast(group->getView("name")); if (pViewName != NULL) { - pViewName->setTextFormatTaged(message); + pViewName->setTextFormatTaged(finalMessage); pViewName->setColor (color); } + // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); @@ -865,7 +894,7 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, textSize = endOfOriginal; } } - + // Output the message in a bubble bool show = false; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e81785ea8..5231dc19a 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2523,6 +2523,17 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat CClientConfig::SSysInfoParam::TMode mode = CClientConfig::SSysInfoParam::Normal; CRGBA color = CRGBA::White; + ucstring cleanStr = str; + ucstring::size_type pos = str.find(ucstring("|")); + if (pos != std::string::npos) + { + ucstring::size_type end = str.find(ucstring("|"), pos+1); + if (end != std::string::npos) + cleanStr = str.substr(pos+1, end-pos-1); + else + cleanStr = str.substr(pos+1); + } + // If broadcast, parse lua code if (toLower(cat) == "bc" && str.size() > 3 && str[0]=='@' && str[1]=='L' && str[2]=='U' && str[3]=='A') { @@ -2542,11 +2553,11 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat if (mode != CClientConfig::SSysInfoParam::OverOnly && mode != CClientConfig::SSysInfoParam::Around) { if (PeopleInterraction.SystemInfo) - PeopleInterraction.ChatInput.SystemInfo.displayMessage(str, color, 2); + PeopleInterraction.ChatInput.SystemInfo.displayMessage(cleanStr, color, 2); else { CPeopleInterraction::CSysMsg sysMsg; - sysMsg.Str = str; + sysMsg.Str = cleanStr; sysMsg.Cat = cat; PeopleInterraction.SystemMessageBuffer.push_back( sysMsg ); } @@ -2557,10 +2568,10 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat // If over popup a string at the bottom of the screen if ((mode == CClientConfig::SSysInfoParam::Over) || (mode == CClientConfig::SSysInfoParam::OverOnly)) - InSceneBubbleManager.addMessagePopup(str, color); + InSceneBubbleManager.addMessagePopup(cleanStr, color); else if ( (mode == CClientConfig::SSysInfoParam::Around || mode == CClientConfig::SSysInfoParam::CenterAround) && PeopleInterraction.AroundMe.Window) - PeopleInterraction.ChatInput.AroundMe.displayMessage(str, color, 2); + PeopleInterraction.ChatInput.AroundMe.displayMessage(cleanStr, color, 2); } From 98b091ab630f3d196110ba066a326605a919b898 Mon Sep 17 00:00:00 2001 From: Nuno Date: Sun, 24 Jan 2021 09:05:51 +0100 Subject: [PATCH 08/11] Added TeleportMarauder --- code/ryzom/common/src/game_share/magic_fx.h | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ryzom/common/src/game_share/magic_fx.h b/code/ryzom/common/src/game_share/magic_fx.h index 2a46475e8..414a6586a 100644 --- a/code/ryzom/common/src/game_share/magic_fx.h +++ b/code/ryzom/common/src/game_share/magic_fx.h @@ -136,6 +136,7 @@ namespace MAGICFX OtherFireWall = 14, TeleportKami = 15, // No effect aura TeleportKara = 16, // No effect aura + TeleportMarauder = 17, // No effect aura }; } From f61d10c75e7b3a6c20844c412975457a9c309d85 Mon Sep 17 00:00:00 2001 From: Nuno Date: Wed, 10 Feb 2021 09:11:03 +0100 Subject: [PATCH 09/11] Added executeRyzomScript, executeTutorial and processTutorialEvent lua callbacks --- code/nel/src/gui/group_html.cpp | 26 ++++++++++++++++--- .../src/interface_v3/group_quick_help.cpp | 2 ++ .../client/src/interface_v3/lua_ihm_ryzom.cpp | 17 ++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 50b381a3c..9531ff216 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -5503,7 +5503,7 @@ namespace NLGUI string suri = elm.getAttribute("href"); if(suri.find("ah:") == 0) { - if (_TrustedDomain) + if (_TrustedDomain || suri.find("ah:script:") == 0) _Link.back() = suri; } else @@ -6360,11 +6360,13 @@ namespace NLGUI void CGroupHTML::htmlOBJECTend(const CHtmlElement &elm) { - if (!_TrustedDomain) - return; + if (_ObjectType=="application/ryzom-data") { + if (!_TrustedDomain) + return; + if (!_ObjectData.empty()) { if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum)) @@ -6374,6 +6376,24 @@ namespace NLGUI _ObjectScript.clear(); } } + else if (_ObjectType=="application/ryzom-tutorial") + { + strFindReplace(_ObjectScript, "[[", "\\[\\["); + strFindReplace(_ObjectScript, "]]", "\\]\\]"); + strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); + strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true); + _ObjectScript.clear(); + } + else if (_ObjectType=="application/ryzom-script") + { + strFindReplace(_ObjectScript, "[[", "\\[\\["); + strFindReplace(_ObjectScript, "]]", "\\]\\]"); + strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); + strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true); + _ObjectScript.clear(); + } _Object = false; } diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 0b789fccf..e89967193 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -74,6 +74,8 @@ bool CGroupQuickHelp::submitEvent (const char *event) // Update the text updateParagraph (); + + CLuaManager::getInstance().executeLuaScript(toString("\ngame:processTutorialEvent(\"%s\")\n", event), true); } } return false; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 35d4042ee..87d2a52b4 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -184,6 +184,23 @@ private: REGISTER_ACTION_HANDLER(CHandlerLUA, "lua"); std::deque > CHandlerLUA::_UICallerStack; +// *************************************************************************** +class CHandlerSCRIPT : public IActionHandler +{ +public: + void execute(CCtrlBase *pCaller, const std::string &sParams) + { + string script = sParams; + strFindReplace(script, "[[", "\\[\\["); + strFindReplace(script, "]]", "\\]\\]"); + strFindReplace(script, "\\[\\[", "]]..'[['..[["); + strFindReplace(script, "\\]\\]", "]]..']]'..[["); + strFindReplace(script, "|", "\n"); + CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+script+"]])\n", true); + } +}; +REGISTER_ACTION_HANDLER(CHandlerSCRIPT, "script"); + // *************************************************************************** // Allow also to call script from expression static DECLARE_INTERFACE_USER_FCT(lua) From df69a1706f1d41e8773547399c9fb84e28903e18 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 11 Feb 2021 14:33:25 +0100 Subject: [PATCH 10/11] Fixed potential security hole --- code/nel/src/gui/group_html.cpp | 12 ++++-------- code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 9531ff216..efb6e9b65 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -6378,19 +6378,15 @@ namespace NLGUI } else if (_ObjectType=="application/ryzom-tutorial") { - strFindReplace(_ObjectScript, "[[", "\\[\\["); - strFindReplace(_ObjectScript, "]]", "\\]\\]"); - strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); - strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + strFindReplace(_ObjectScript, "[", "〈"); + strFindReplace(_ObjectScript, "]", "〉"); CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } else if (_ObjectType=="application/ryzom-script") { - strFindReplace(_ObjectScript, "[[", "\\[\\["); - strFindReplace(_ObjectScript, "]]", "\\]\\]"); - strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); - strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + strFindReplace(_ObjectScript, "[", "〈"); + strFindReplace(_ObjectScript, "]", "〉"); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 87d2a52b4..32b37eb61 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -191,10 +191,8 @@ public: void execute(CCtrlBase *pCaller, const std::string &sParams) { string script = sParams; - strFindReplace(script, "[[", "\\[\\["); - strFindReplace(script, "]]", "\\]\\]"); - strFindReplace(script, "\\[\\[", "]]..'[['..[["); - strFindReplace(script, "\\]\\]", "]]..']]'..[["); + strFindReplace(script, "[", "〈"); + strFindReplace(script, "]", "〉"); strFindReplace(script, "|", "\n"); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+script+"]])\n", true); } From 2aaa928cdcf9bf282b96da8b90098f74b01cdd52 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 11 Feb 2021 14:48:15 +0100 Subject: [PATCH 11/11] Fixed potential security hole --- code/nel/src/gui/group_html.cpp | 8 ++++---- code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index efb6e9b65..e88bdfbc5 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -6378,15 +6378,15 @@ namespace NLGUI } else if (_ObjectType=="application/ryzom-tutorial") { - strFindReplace(_ObjectScript, "[", "〈"); - strFindReplace(_ObjectScript, "]", "〉"); + while(strFindReplace(_ObjectScript, "[", "〈")); + while(strFindReplace(_ObjectScript, "]", "〉")); CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } else if (_ObjectType=="application/ryzom-script") { - strFindReplace(_ObjectScript, "[", "〈"); - strFindReplace(_ObjectScript, "]", "〉"); + while(strFindReplace(_ObjectScript, "[", "〈")); + while(strFindReplace(_ObjectScript, "]", "〉")); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 32b37eb61..ca5de98c8 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -191,8 +191,8 @@ public: void execute(CCtrlBase *pCaller, const std::string &sParams) { string script = sParams; - strFindReplace(script, "[", "〈"); - strFindReplace(script, "]", "〉"); + while(strFindReplace(script, "[", "〈")); + while(strFindReplace(script, "]", "〉")); strFindReplace(script, "|", "\n"); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+script+"]])\n", true); }