Merge with develop

This commit is contained in:
kervala 2016-12-18 20:44:33 +01:00
parent bb28b25e71
commit 1e8d28759a
17 changed files with 291 additions and 240 deletions

View file

@ -1,5 +1,3 @@
PROJECT(NeL CXX C)
IF(WITH_STATIC_DRIVERS) IF(WITH_STATIC_DRIVERS)
ADD_DEFINITIONS(-DNL_STATIC) ADD_DEFINITIONS(-DNL_STATIC)
ENDIF() ENDIF()
@ -17,7 +15,6 @@ IF(WITH_3D)
IF(WITH_NEL_CEGUI) IF(WITH_NEL_CEGUI)
FIND_PACKAGE(CEGUI) FIND_PACKAGE(CEGUI)
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(WITH_SOUND) IF(WITH_SOUND)

View file

@ -289,7 +289,7 @@ bool CForm::insertParent (uint before, const std::string &filename, CForm *paren
else else
{ {
// Output an error // Output an error
warning (false, "insertParent", "Can't insert parent form (%s) that has not the same DFN.", filename); warning (false, "insertParent", "Can't insert parent form (%s) that has not the same DFN.", filename.c_str());
} }
return false; return false;

View file

@ -171,7 +171,7 @@ CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad)
else else
{ {
// Output error // Output error
warning (false, "loadFormDfn", "Can't open the form file (%s).", filename); warning (false, "loadFormDfn", "Can't open the form file (%s).", filename.c_str());
// Delete the formDfn // Delete the formDfn
delete formDfn; delete formDfn;
@ -182,7 +182,7 @@ CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad)
catch (const Exception &e) catch (const Exception &e)
{ {
// Output error // Output error
warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename, e.what()); warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename.c_str(), e.what());
// Delete the formDfn // Delete the formDfn
delete formDfn; delete formDfn;
@ -257,7 +257,7 @@ UForm *CFormLoader::loadForm (const std::string &filename)
else else
{ {
// Output error // Output error
warning (false, "loadForm", "Can't open the form file (%s).", filename); warning (false, "loadForm", "Can't open the form file (%s).", filename.c_str());
// Delete the form // Delete the form
delete form; delete form;
@ -279,7 +279,7 @@ UForm *CFormLoader::loadForm (const std::string &filename)
catch (const Exception &e) catch (const Exception &e)
{ {
// Output error // Output error
warning (false, "loadForm", "Error while loading the form (%s): %s", filename, e.what()); warning (false, "loadForm", "Error while loading the form (%s): %s", filename.c_str(), e.what());
// Delete the form // Delete the form
delete form; delete form;
@ -317,7 +317,7 @@ void CFormLoader::warning (bool exception, const std::string &function, const ch
va_end( args ); va_end( args );
// Set the warning // Set the warning
NLGEORGES::warning (exception, "(CFormLoader::%s) : %s", function, buffer); NLGEORGES::warning (exception, "(CFormLoader::%s) : %s", function.c_str(), buffer);
} }
// *************************************************************************** // ***************************************************************************

View file

@ -831,14 +831,15 @@ void CUnifiedNetwork::addService(const string &name, const vector<CInetAddress>
uint j = 0; uint j = 0;
// it's loopback ip address, it's ok
if (!addr[i].isLoopbackIPAddress()) if (!addr[i].isLoopbackIPAddress())
{ {
// it's loopback ip address, it's ok
for (j = 0; j < laddr.size (); j++) for (j = 0; j < laddr.size (); j++)
{ {
if (laddr[j].internalNetAddress () == addr[i].internalNetAddress ()) if (laddr[j].internalNetAddress () == addr[i].internalNetAddress ())
{ {
break; // it's ok, we can try // it's ok, we can try
break;
} }
} }
@ -1272,7 +1273,8 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid)
uint8 connectionId = _IdCnx[sid.get()].DefaultNetwork; uint8 connectionId = _IdCnx[sid.get()].DefaultNetwork;
if (nid == 0xFF) if (nid == 0xFF)
{ // default network {
// default network
//nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId); //nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId);
} }
else if (nid >= _IdCnx[sid.get()].NetworkConnectionAssociations.size()) else if (nid >= _IdCnx[sid.get()].NetworkConnectionAssociations.size())
@ -1293,7 +1295,6 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid)
if (connectionId >= _IdCnx[sid.get()].Connections.size() || !_IdCnx[sid.get()].Connections[connectionId].valid() || !_IdCnx[sid.get()].Connections[connectionId].CbNetBase->connected()) if (connectionId >= _IdCnx[sid.get()].Connections.size() || !_IdCnx[sid.get()].Connections[connectionId].valid() || !_IdCnx[sid.get()].Connections[connectionId].CbNetBase->connected())
{ {
if (nid != 0xFF) if (nid != 0xFF)
{ {
// not a default network. There's a problem with the selected connectionID, so try to find a valid one // not a default network. There's a problem with the selected connectionID, so try to find a valid one

View file

@ -732,9 +732,8 @@ bool CEntityManager::instancesRemoved()
return instRemoved; return instRemoved;
} }
bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const vector<string> &values)
{
bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const vector<string> &values) {
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted) if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
return false; return false;
@ -881,6 +880,8 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
primitive->setObstacle(active); primitive->setObstacle(active);
} }
} }
return true;
} }

View file

@ -2654,7 +2654,6 @@ class CAHAddShape : public IActionHandler
}; };
REGISTER_ACTION_HANDLER (CAHAddShape, "add_shape"); REGISTER_ACTION_HANDLER (CAHAddShape, "add_shape");
class CAHRemoveShapes : public IActionHandler class CAHRemoveShapes : public IActionHandler
{ {
virtual void execute (CCtrlBase * /* pCaller */, const string &Params) virtual void execute (CCtrlBase * /* pCaller */, const string &Params)

View file

@ -199,12 +199,14 @@ static DECLARE_INTERFACE_USER_FCT(lua)
ls.pushNil(); ls.pushNil();
ls.setTable(-3); //pop pop ls.setTable(-3); //pop pop
ls.pop(); ls.pop();
// *** execute script // *** execute script
std::string script = args[0].getString(); std::string script = args[0].getString();
// assign return value in retId. // assign return value in retId.
script = retId + "= " + script; script = retId + "= " + script;
// execute a small script here, because most often exprs are called from xml files => lot of redundant script // execute a small script here, because most often exprs are called from xml files => lot of redundant script
CLuaManager::getInstance().executeLuaScript(script, true); CLuaManager::getInstance().executeLuaScript(script, true);
// *** retrieve and convert return value // *** retrieve and convert return value
ls.pushGlobalTable(); ls.pushGlobalTable();
ls.push(retId); ls.push(retId);
@ -254,6 +256,7 @@ static DECLARE_INTERFACE_USER_FCT(lua)
else if (type == LUA_TUSERDATA) else if (type == LUA_TUSERDATA)
{ {
// NB: the value is poped in obj.set() (no need to do ls.pop()); // NB: the value is poped in obj.set() (no need to do ls.pop());
// try with ucstring // try with ucstring
ucstring ucstrVal; ucstring ucstrVal;
@ -378,6 +381,7 @@ void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str)
void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls)
{ {
CLuaStackChecker lsc(&ls); CLuaStackChecker lsc(&ls);
// MISC ui ctors // MISC ui ctors
struct CUICtor struct CUICtor
{ {
@ -389,7 +393,9 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls)
return 1; return 1;
} }
}; };
ls.registerFunc("SNode", CUICtor::SNode); ls.registerFunc("SNode", CUICtor::SNode);
// *** Register the metatable for access to client.cfg (nb nico this may be more general later -> access to any config file ...) // *** Register the metatable for access to client.cfg (nb nico this may be more general later -> access to any config file ...)
ls.pushGlobalTable(); ls.pushGlobalTable();
CLuaObject globals(ls); CLuaObject globals(ls);
@ -399,6 +405,7 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls)
mt.setValue("__index", luaClientCfgIndex); mt.setValue("__index", luaClientCfgIndex);
mt.setValue("__newindex", luaClientCfgNewIndex); mt.setValue("__newindex", luaClientCfgNewIndex);
globals.setNil("__cfmt"); // remove temp metatable globals.setNil("__cfmt"); // remove temp metatable
ls.registerFunc("getUI", getUI); ls.registerFunc("getUI", getUI);
ls.registerFunc("validMessageBox", validMessageBox); ls.registerFunc("validMessageBox", validMessageBox);
ls.registerFunc("getUICaller", getUICaller); ls.registerFunc("getUICaller", getUICaller);
@ -477,8 +484,10 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls)
ls.registerFunc("setupShape", setupShape); ls.registerFunc("setupShape", setupShape);
lua_State *L = ls.getStatePointer(); lua_State *L = ls.getStatePointer();
LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString); LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString);
LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "game.TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString); LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "game.TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString);
luabind::module(L) luabind::module(L)
[ [
LUABIND_FUNC(getDbProp), LUABIND_FUNC(getDbProp),
@ -626,6 +635,7 @@ int CLuaIHMRyzom::getUI(CLuaState &ls)
// get the string // get the string
std::string eltStr; std::string eltStr;
ls.toString(1, eltStr); ls.toString(1, eltStr);
// return the element // return the element
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(eltStr); CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(eltStr);
@ -655,13 +665,16 @@ int CLuaIHMRyzom::formatUI(CLuaState &ls)
{ {
//H_AUTO(Lua_CLuaIHM_formatUI) //H_AUTO(Lua_CLuaIHM_formatUI)
CLuaStackChecker lsc(&ls, 1); CLuaStackChecker lsc(&ls, 1);
// params: "expr", param1, param2.... // params: "expr", param1, param2....
// return: string with # and % parsed // return: string with # and % parsed
CLuaIHM::checkArgMin(ls, "formatUI", 1); CLuaIHM::checkArgMin(ls, "formatUI", 1);
CLuaIHM::check(ls, ls.isString(1), "formatUI() require a string in param1"); CLuaIHM::check(ls, ls.isString(1), "formatUI() require a string in param1");
// get the string to format // get the string to format
std::string propVal; std::string propVal;
ls.toString(1, propVal); ls.toString(1, propVal);
// *** format with % // *** format with %
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
std::string newPropVal, defError; std::string newPropVal, defError;
@ -679,6 +692,7 @@ int CLuaIHMRyzom::formatUI(CLuaState &ls)
{ {
std::string paramValue; std::string paramValue;
ls.toString(stackIndex, paramValue); ls.toString(stackIndex, paramValue);
// For stack param 4, the param index is 3 (because stack param 2 is the param No 1) // For stack param 4, the param index is 3 (because stack param 2 is the param No 1)
sint paramIndex = stackIndex - 1; sint paramIndex = stackIndex - 1;
@ -698,10 +712,12 @@ int CLuaIHMRyzom::formatDB(CLuaState &ls)
{ {
//H_AUTO(Lua_CLuaIHM_formatDB) //H_AUTO(Lua_CLuaIHM_formatDB)
CLuaStackChecker lsc(&ls, 1); CLuaStackChecker lsc(&ls, 1);
// params: param1, param2.... // params: param1, param2....
// return: string with @ and , added // return: string with @ and , added
CLuaIHM::checkArgMin(ls, "formatDB", 1); CLuaIHM::checkArgMin(ls, "formatDB", 1);
uint top = ls.getTop(); uint top = ls.getTop();
std::string dbRes; std::string dbRes;
for (uint i = 1; i <= top; i++) for (uint i = 1; i <= top; i++)
@ -726,10 +742,12 @@ int CLuaIHMRyzom::dumpUI(CLuaState &ls)
{ {
//H_AUTO(Lua_CLuaIHM_dumpUI) //H_AUTO(Lua_CLuaIHM_dumpUI)
CLuaStackChecker lsc(&ls, 0); CLuaStackChecker lsc(&ls, 0);
// params: CInterfaceElement * // params: CInterfaceElement *
// return: none // return: none
CLuaIHM::checkArgCount(ls, "dumpUI", 1); CLuaIHM::checkArgCount(ls, "dumpUI", 1);
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1"); CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1");
// retrieve args // retrieve args
CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1); CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
@ -753,7 +771,9 @@ int CLuaIHMRyzom::setKeyboardContext(CLuaState &ls)
const char *funcName = "setKeyboardContext"; const char *funcName = "setKeyboardContext";
CLuaIHM::checkArgMin(ls, funcName, 1); CLuaIHM::checkArgMin(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
ActionsContext.setContext(ls.toString(1)); ActionsContext.setContext(ls.toString(1));
return 0; return 0;
} }
@ -803,9 +823,11 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls)
// params: CViewText*, "text" (or ucstring) // params: CViewText*, "text" (or ucstring)
// return: none // return: none
CLuaIHM::checkArgCount(ls, "setTextFormatTaged", 2); CLuaIHM::checkArgCount(ls, "setTextFormatTaged", 2);
// *** check and retrieve param 1 // *** check and retrieve param 1
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1"); CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1");
CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1); CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
// *** check and retrieve param 2. must be a string or a ucstring // *** check and retrieve param 2. must be a string or a ucstring
ucstring text; ucstring text;
@ -833,6 +855,7 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls)
// Set the text as format // Set the text as format
vt->setTextFormatTaged(text); vt->setTextFormatTaged(text);
return 0; return 0;
} }
@ -853,8 +876,10 @@ struct CEmoteStruct
{ {
string::size_type pos1 = path1.find('|'); string::size_type pos1 = path1.find('|');
string::size_type pos2 = path2.find('|'); string::size_type pos2 = path2.find('|');
ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1))); ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1)));
ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2))); ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2)));
sint result = s1.compare(s2); sint result = s1.compare(s2);
if (result != 0) if (result != 0)
@ -880,14 +905,16 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
//H_AUTO(Lua_CLuaIHM_initEmotesMenu) //H_AUTO(Lua_CLuaIHM_initEmotesMenu)
CLuaIHM::checkArgCount(ls, "initEmotesMenu", 2); CLuaIHM::checkArgCount(ls, "initEmotesMenu", 2);
CLuaIHM::checkArgType(ls, "initEmotesMenu", 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, "initEmotesMenu", 2, LUA_TSTRING);
const std::string &emoteMenu = ls.toString(1); const std::string &emoteMenu = ls.toString(1);
const std::string &luaParams = ls.toString(2); const std::string &luaParams = ls.toString(2);
ls.newTable(); ls.newTable();
CLuaObject result(ls); CLuaObject result(ls);
std::map<std::string, std::string> emoteList; std::map<std::string, std::string> emoteList;
uint maxVisibleLine = 10; uint maxVisibleLine = 10;
CTextEmotListSheet* pTELS = dynamic_cast<CTextEmotListSheet*>(SheetMngr.get(CSheetId("list.text_emotes")));
CTextEmotListSheet *pTELS = dynamic_cast<CTextEmotListSheet*>(SheetMngr.get(CSheetId("list.text_emotes")));
if (pTELS == NULL) if (pTELS == NULL)
return 0; return 0;
@ -914,8 +941,10 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
nlassert(pEmotList->Emots.size() <= 255); nlassert(pEmotList->Emots.size() <= 255);
// Get the focus beta tester flag // Get the focus beta tester flag
bool betaTester = false; bool betaTester = false;
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
CSkillManager *pSM = CSkillManager::getInstance(); CSkillManager *pSM = CSkillManager::getInstance();
betaTester = pSM->isTitleUnblocked(CHARACTER_TITLE::FBT); betaTester = pSM->isTitleUnblocked(CHARACTER_TITLE::FBT);
CGroupMenu *pInitRootMenu = dynamic_cast<CGroupMenu*>(CWidgetManager::getInstance()->getElementFromId(emoteMenu)); CGroupMenu *pInitRootMenu = dynamic_cast<CGroupMenu*>(CWidgetManager::getInstance()->getElementFromId(emoteMenu));
pInitRootMenu->reset(); pInitRootMenu->reset();
@ -1016,6 +1045,7 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
} }
result.push(); result.push();
return 1; return 1;
} }
@ -1115,8 +1145,10 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls)
//H_AUTO(Lua_CLuaIHM_enableModalWindow) //H_AUTO(Lua_CLuaIHM_enableModalWindow)
const char *funcName = "enableModalWindow"; const char *funcName = "enableModalWindow";
CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1"); CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1");
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1); CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
std::string modalId = ls.toString(2); std::string modalId = ls.toString(2);
@ -1133,6 +1165,7 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls)
if (group) if (group)
{ {
UserControls.stopFreeLook(); UserControls.stopFreeLook();
// enable the modal // enable the modal
CWidgetManager::getInstance()->enableModalWindow(ctrl, group); CWidgetManager::getInstance()->enableModalWindow(ctrl, group);
} }
@ -1223,8 +1256,6 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls)
return 1; return 1;
} }
int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls) int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls)
{ {
sint32 x, y; sint32 x, y;
@ -1263,9 +1294,6 @@ int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls)
return 3; return 3;
} }
// *************************************************************************** // ***************************************************************************
int CLuaIHMRyzom::getPlayerPos(CLuaState &ls) int CLuaIHMRyzom::getPlayerPos(CLuaState &ls)
{ {
@ -1457,14 +1485,18 @@ int CLuaIHMRyzom::disableContextHelpForControl(CLuaState &ls)
{ {
//H_AUTO(Lua_CLuaIHM_disableContextHelpForControl) //H_AUTO(Lua_CLuaIHM_disableContextHelpForControl)
CLuaStackChecker lsc(&ls, 0); CLuaStackChecker lsc(&ls, 0);
// params: CCtrlBase* // params: CCtrlBase*
// return: none // return: none
CLuaIHM::checkArgCount(ls, "disableContextHelpForControl", 1); CLuaIHM::checkArgCount(ls, "disableContextHelpForControl", 1);
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1"); CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1");
// retrieve args // retrieve args
CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1); CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
// go // go
CWidgetManager::getInstance()->disableContextHelpForControl(dynamic_cast<CCtrlBase*>(pIE)); CWidgetManager::getInstance()->disableContextHelpForControl(dynamic_cast<CCtrlBase*>(pIE));
return 0; return 0;
} }
@ -1511,8 +1543,10 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls)
CLuaIHM::checkArgCount(ls, "getSheet2idx", 2); CLuaIHM::checkArgCount(ls, "getSheet2idx", 2);
CLuaIHM::checkArgType(ls, "getSheet2idx", 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, "getSheet2idx", 1, LUA_TSTRING);
CLuaIHM::checkArgType(ls, "getSheet2idx", 2, LUA_TNUMBER); CLuaIHM::checkArgType(ls, "getSheet2idx", 2, LUA_TNUMBER);
const std::string &sheedtName = ls.toString(1); const std::string &sheedtName = ls.toString(1);
uint32 slotId = (uint32)ls.toInteger(2); uint32 slotId = (uint32)ls.toInteger(2);
NLMISC::CSheetId sheetId; NLMISC::CSheetId sheetId;
if (sheetId.buildSheetId(sheedtName)) if (sheetId.buildSheetId(sheedtName))
@ -1539,6 +1573,7 @@ int CLuaIHMRyzom::getSlotDataSetId(CLuaState &ls)
{ {
CLuaIHM::checkArgCount(ls, "getSlotDataSetId", 1); CLuaIHM::checkArgCount(ls, "getSlotDataSetId", 1);
CLuaIHM::checkArgType(ls, "getSlotDataSetId", 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, "getSlotDataSetId", 1, LUA_TNUMBER);
uint32 slot = (uint32)ls.toInteger(1); uint32 slot = (uint32)ls.toInteger(1);
CEntityCL *e = getSlotEntity(slot); CEntityCL *e = getSlotEntity(slot);
string id = toString(e->dataSetId()); string id = toString(e->dataSetId());
@ -1553,6 +1588,7 @@ int CLuaIHMRyzom::getClientCfgVar(CLuaState &ls)
CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
std::string varName = ls.toString(1); std::string varName = ls.toString(1);
CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(varName); CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(varName);
if (!v) return 0; if (!v) return 0;
@ -1657,6 +1693,7 @@ int CLuaIHMRyzom::getUICaller(CLuaState &ls)
{ {
//H_AUTO(Lua_CLuaIHM_getUICaller) //H_AUTO(Lua_CLuaIHM_getUICaller)
CLuaStackChecker lsc(&ls, 1); CLuaStackChecker lsc(&ls, 1);
// params: none. // params: none.
// return: CInterfaceElement* (nil if error) // return: CInterfaceElement* (nil if error)
CInterfaceElement *pIE = CHandlerLUA::getUICaller(); CInterfaceElement *pIE = CHandlerLUA::getUICaller();
@ -1679,10 +1716,12 @@ int CLuaIHMRyzom::getIndexInDB(CLuaState &ls)
{ {
//H_AUTO(Lua_CLuaIHM_getIndexInDB) //H_AUTO(Lua_CLuaIHM_getIndexInDB)
CLuaStackChecker lsc(&ls, 1); CLuaStackChecker lsc(&ls, 1);
// params: CDBCtrlSheet* // params: CDBCtrlSheet*
// return: index in DB of a dbctrlsheet (empty if error) // return: index in DB of a dbctrlsheet (empty if error)
CLuaIHM::checkArgCount(ls, "getIndexInDB", 1); CLuaIHM::checkArgCount(ls, "getIndexInDB", 1);
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1"); CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1");
// retrieve args // retrieve args
CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1); CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(pIE); CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(pIE);
@ -1866,7 +1905,9 @@ int CLuaIHMRyzom::displayBubble(CLuaState &ls)
links.push_back(it.nextValue().toString()); links.push_back(it.nextValue().toString());
strs.push_back(it.nextKey().toString()); strs.push_back(it.nextKey().toString());
} }
InSceneBubbleManager.webIgChatOpen((uint32)ls.toInteger(1), ls.toString(2), strs, links); InSceneBubbleManager.webIgChatOpen((uint32)ls.toInteger(1), ls.toString(2), strs, links);
return 1; return 1;
} }
@ -1922,11 +1963,14 @@ int CLuaIHMRyzom::getCompleteIslands(CLuaState &ls)
//H_AUTO(Lua_CLuaIHM_getCompleteIslands) //H_AUTO(Lua_CLuaIHM_getCompleteIslands)
const char *funcName = "getCompleteIslands"; const char *funcName = "getCompleteIslands";
CLuaIHM::checkArgCount(ls, funcName, 0); CLuaIHM::checkArgCount(ls, funcName, 0);
ls.newTable(); ls.newTable();
CLuaObject result(ls); CLuaObject result(ls);
// load entryPoints // load entryPoints
CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance(); CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance();
const CScenarioEntryPoints::TCompleteIslands &islands = scenarioEntryPoints.getCompleteIslands(); const CScenarioEntryPoints::TCompleteIslands &islands = scenarioEntryPoints.getCompleteIslands();
CScenarioEntryPoints::TCompleteIslands::const_iterator island(islands.begin()), lastIsland(islands.end()); CScenarioEntryPoints::TCompleteIslands::const_iterator island(islands.begin()), lastIsland(islands.end());
for (; island != lastIsland ; ++island) for (; island != lastIsland ; ++island)
@ -1938,6 +1982,7 @@ int CLuaIHMRyzom::getCompleteIslands(CLuaState &ls)
islandTable.setValue("ymin", island->YMin); islandTable.setValue("ymin", island->YMin);
islandTable.setValue("xmax", island->XMax); islandTable.setValue("xmax", island->XMax);
islandTable.setValue("ymax", island->YMax); islandTable.setValue("ymax", island->YMax);
ls.newTable(); ls.newTable();
CLuaObject entrypointsTable(ls); CLuaObject entrypointsTable(ls);
@ -1948,25 +1993,28 @@ int CLuaIHMRyzom::getCompleteIslands(CLuaState &ls)
CLuaObject entrypointTable(ls); CLuaObject entrypointTable(ls);
entrypointTable.setValue("x", entryPoint.X); entrypointTable.setValue("x", entryPoint.X);
entrypointTable.setValue("y", entryPoint.Y); entrypointTable.setValue("y", entryPoint.Y);
entrypointsTable.setValue(entryPoint.Location, entrypointTable); entrypointsTable.setValue(entryPoint.Location, entrypointTable);
} }
islandTable.setValue("entrypoints", entrypointsTable); islandTable.setValue("entrypoints", entrypointsTable);
result.setValue(island->Island, islandTable); result.setValue(island->Island, islandTable);
} }
result.push(); result.push();
return 1; return 1;
} }
// *************************************************************************** // ***************************************************************************
int CLuaIHMRyzom::getIslandId(CLuaState &ls) int CLuaIHMRyzom::getIslandId(CLuaState &ls)
{ {
//H_AUTO(Lua_CLuaIHM_getIslandId) //H_AUTO(Lua_CLuaIHM_getIslandId)
const char *funcName = "getIslandId"; const char *funcName = "getIslandId";
CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::check(ls, ls.isString(1), "getIslandId() requires a string in param 1"); CLuaIHM::check(ls, ls.isString(1), "getIslandId() requires a string in param 1");
CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance(); CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance();
uint32 id = scenarioEntryPoints.getIslandId(ls.toString(1)); uint32 id = scenarioEntryPoints.getIslandId(ls.toString(1));
ls.push(id); ls.push(id);
@ -2532,11 +2580,11 @@ void CLuaIHMRyzom::setDbProp(const std::string &dbProp, sint32 value)
static const std::string dbLocal = "LOCAL:"; static const std::string dbLocal = "LOCAL:";
static const std::string dbLocalR2 = "LOCAL:R2"; static const std::string dbLocalR2 = "LOCAL:R2";
if ((0 == dbProp.compare(0, dbServer.size(), dbServer)) || if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) ||
(0 == dbProp.compare(0, dbLocal.size(), dbLocal)) (dbProp.compare(0, dbLocal.size(), dbLocal) == 0)
) )
{ {
if (0 != dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0)
{ {
nlstop; nlstop;
throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
@ -2561,11 +2609,11 @@ void CLuaIHMRyzom::delDbProp(const string &dbProp)
static const string dbLocal = "LOCAL:"; static const string dbLocal = "LOCAL:";
static const string dbLocalR2 = "LOCAL:R2"; static const string dbLocalR2 = "LOCAL:R2";
if ((0 == dbProp.compare(0, dbServer.size(), dbServer)) || if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) ||
(0 == dbProp.compare(0, dbLocal.size(), dbLocal)) (dbProp.compare(0, dbLocal.size(), dbLocal) == 0)
) )
{ {
if (0 != dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0)
{ {
nlstop; nlstop;
throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
@ -2585,11 +2633,11 @@ void CLuaIHMRyzom::addDbProp(const std::string &dbProp, sint32 value)
static const std::string dbLocal = "LOCAL:"; static const std::string dbLocal = "LOCAL:";
static const std::string dbLocalR2 = "LOCAL:R2"; static const std::string dbLocalR2 = "LOCAL:R2";
if ((0 == dbProp.compare(0, dbServer.size(), dbServer)) || if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) ||
(0 == dbProp.compare(0, dbLocal.size(), dbLocal)) (dbProp.compare(0, dbLocal.size(), dbLocal) == 0)
) )
{ {
if (0 != dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0)
{ {
nlstop; nlstop;
throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
@ -2865,6 +2913,7 @@ ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 paramet
ucstring result = str; ucstring result = str;
CSString s = str.toString(); CSString s = str.toString();
std::string p, paramString; std::string p, paramString;
// Locate parameter and store it // Locate parameter and store it
p = s.splitTo('%', true); p = s.splitTo('%', true);
@ -2904,6 +2953,7 @@ ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 paramet
} }
strFindReplace(result, paramString.c_str(), p); strFindReplace(result, paramString.c_str(), p);
return result; return result;
} }
@ -3042,6 +3092,7 @@ sint32 CLuaIHMRyzom::getMagicResistChance(bool elementalSpell, sint32 casterSp
sint32 chanceToHit = pPM->getSuccessRate(elementalSpell ? CSPhraseManager::STResistMagic : CSPhraseManager::STResistMagicLink, sint32 chanceToHit = pPM->getSuccessRate(elementalSpell ? CSPhraseManager::STResistMagic : CSPhraseManager::STResistMagicLink,
casterSpellLvl - victimResistLvl, true); casterSpellLvl - victimResistLvl, true);
clamp(chanceToHit, 0, 100); clamp(chanceToHit, 0, 100);
// Thus, the resist chance is 100 - hit chance. // Thus, the resist chance is 100 - hit chance.
return 100 - chanceToHit; return 100 - chanceToHit;
} }
@ -3053,8 +3104,10 @@ sint32 CLuaIHMRyzom::getDodgeParryChance(sint32 attLvl, sint32 defLvl)
CSPhraseManager *pPM = CSPhraseManager::getInstance(); CSPhraseManager *pPM = CSPhraseManager::getInstance();
attLvl = std::max(attLvl, sint32(0)); attLvl = std::max(attLvl, sint32(0));
defLvl = std::max(defLvl, sint32(0)); defLvl = std::max(defLvl, sint32(0));
sint32 chance = pPM->getSuccessRate(CSPhraseManager::STDodgeParry, defLvl - attLvl, false); sint32 chance = pPM->getSuccessRate(CSPhraseManager::STDodgeParry, defLvl - attLvl, false);
clamp(chance, 0, 100); clamp(chance, 0, 100);
return chance; return chance;
} }
@ -3069,6 +3122,7 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string
{ {
// if true, it means that we want to display a web page that use webig auth // if true, it means that we want to display a web page that use webig auth
bool webig = urlIn.find("http://") == 0; bool webig = urlIn.find("http://") == 0;
string url; string url;
// append the WebServer to the url // append the WebServer to the url
@ -3121,6 +3175,7 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string
*/ */
// set the wanted timeout // set the wanted timeout
groupHtml->setTimeout((float)std::max(0.0, timeout)); groupHtml->setTimeout((float)std::max(0.0, timeout));
// Browse the url // Browse the url
groupHtml->clean(); groupHtml->clean();
groupHtml->browse(url.c_str()); groupHtml->browse(url.c_str());
@ -3393,10 +3448,11 @@ sint32 CLuaIHMRyzom::getGroundZ(uint32 x, sint32 y)
vect.y = y; vect.y = y;
UserEntity->getCollisionEntity()->snapToGround(vect); UserEntity->getCollisionEntity()->snapToGround(vect);
return vect.z; return vect.z;
} }
void setMouseCursor(const std::string texture) void setMouseCursor(const std::string &texture)
{ {
if (texture.empty()) if (texture.empty())
CTool::setMouseCursor("curs_default.tga"); CTool::setMouseCursor("curs_default.tga");
@ -3451,7 +3507,6 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg)
} }
} }
// *************************************************************************** // ***************************************************************************
bool CLuaIHMRyzom::isRingAccessPointInReach() bool CLuaIHMRyzom::isRingAccessPointInReach()
{ {
@ -3558,7 +3613,6 @@ sint32 CLuaIHMRyzom::getTargetLevel()
ucstring CLuaIHMRyzom::getTargetSheet() ucstring CLuaIHMRyzom::getTargetSheet()
{ {
CEntityCL *target = getTargetEntity(); CEntityCL *target = getTargetEntity();
if (!target) return ucstring(); if (!target) return ucstring();
return target->sheetId().toString(); return target->sheetId().toString();
@ -3568,10 +3622,10 @@ ucstring CLuaIHMRyzom::getTargetSheet()
sint64 CLuaIHMRyzom::getTargetVpa() sint64 CLuaIHMRyzom::getTargetVpa()
{ {
CEntityCL *target = getTargetEntity(); CEntityCL *target = getTargetEntity();
if (!target) return 0; if (!target) return 0;
sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64();
return prop; return prop;
} }
@ -3579,10 +3633,10 @@ sint64 CLuaIHMRyzom::getTargetVpa()
sint64 CLuaIHMRyzom::getTargetVpb() sint64 CLuaIHMRyzom::getTargetVpb()
{ {
CEntityCL *target = getTargetEntity(); CEntityCL *target = getTargetEntity();
if (!target) return 0; if (!target) return 0;
sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
return prop; return prop;
} }
@ -3590,10 +3644,10 @@ sint64 CLuaIHMRyzom::getTargetVpb()
sint64 CLuaIHMRyzom::getTargetVpc() sint64 CLuaIHMRyzom::getTargetVpc()
{ {
CEntityCL *target = getTargetEntity(); CEntityCL *target = getTargetEntity();
if (!target) return 0; if (!target) return 0;
sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
return prop; return prop;
} }

View file

@ -219,7 +219,7 @@ private:
static int getMouseRightDown(CLuaState &ls); static int getMouseRightDown(CLuaState &ls);
static int getShapeIdAt(CLuaState &ls); static int getShapeIdAt(CLuaState &ls);
static int setupShape(CLuaState &ls); static int setupShape(CLuaState &ls);
static void setMouseCursor(const std::string texture); static void setMouseCursor(const std::string &texture);
// open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly // 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' // else, current command of the chat window will be replaced with tell 'player'
static void tell(const ucstring &player, const ucstring &msg); static void tell(const ucstring &player, const ucstring &msg);

View file

@ -797,7 +797,7 @@ bool CTool::isMouseCaptured()
} }
// ********************************************************************************************************* // *********************************************************************************************************
void CTool::setMouseCursor(const char *cursorTexture) void CTool::setMouseCursor(const std::string &cursorTexture)
{ {
//H_AUTO(R2_CTool_setMouseCursor) //H_AUTO(R2_CTool_setMouseCursor)
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );

View file

@ -224,8 +224,7 @@ public:
// Get mouse y position // Get mouse y position
static sint32 getMouseY(); static sint32 getMouseY();
// Set the current mouse cursor // Set the current mouse cursor
static void setMouseCursor(const char *cursorTexture); static void setMouseCursor(const std::string &cursorTexture);
static void setMouseCursor(const std::string &cursorTexture) { setMouseCursor(cursorTexture.c_str()); }
/** Compute a view vector (with its direction z set to 1) from coordinate of the mouse on screen /** Compute a view vector (with its direction z set to 1) from coordinate of the mouse on screen
* If the mouse is on the island map, then a vector looking down from heights will be returned * If the mouse is on the island map, then a vector looking down from heights will be returned
*/ */

View file

@ -414,21 +414,21 @@ void CToolChoosePos::updateBeforeRender()
{ {
if (_MultiPos && isShiftDown() && !_MultiPosLocked) if (_MultiPos && isShiftDown() && !_MultiPosLocked)
{ {
setMouseCursor(_CursValidMulti.c_str()); setMouseCursor(_CursValidMulti);
} }
else else
{ {
setMouseCursor(_CursValid.c_str()); setMouseCursor(_CursValid);
} }
} }
else else
{ {
setMouseCursor(_CursInvalid.c_str()); setMouseCursor(_CursInvalid);
} }
} }
else else
{ {
setMouseCursor(_CursValid.c_str()); setMouseCursor(_CursValid);
} }
} }

View file

@ -596,7 +596,7 @@ void CToolCreateEntity::updateBeforeRender()
} }
CGroupMap *worldMap = getWorldMap(); CGroupMap *worldMap = getWorldMap();
if (worldMap) worldMap->setSelectionAxis(_ValidArray); if (worldMap) worldMap->setSelectionAxis(_ValidArray);
setMouseCursor(_ValidArray ? _CursValid.c_str() : _CursInvalid.c_str()); setMouseCursor(_ValidArray ? _CursValid : _CursInvalid);
} }
// *************************************************************** // ***************************************************************