From 3ee1b080136baa95c2e243b573eb38296abc2ae5 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 14 Nov 2015 11:46:17 +0100 Subject: [PATCH] Changed: Support for integer types in Lua 5.3, fixes #253 --- code/nel/include/nel/gui/lua_helper.h | 12 +++- code/nel/include/nel/gui/lua_helper_inline.h | 72 +++++++++++++++++-- code/nel/src/gui/dbgroup_combo_box.cpp | 2 +- code/nel/src/gui/group_list.cpp | 2 +- code/nel/src/gui/group_menu.cpp | 4 +- code/nel/src/gui/group_tree.cpp | 2 +- code/nel/src/gui/interface_group.cpp | 2 +- code/nel/src/gui/lua_ihm.cpp | 16 ++--- .../client/src/interface_v3/dbctrl_sheet.cpp | 8 +-- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 32 ++++----- .../src/interface_v3/sphrase_manager.cpp | 36 +++++----- .../src/r2/dmc/client_edition_module.cpp | 10 +-- code/ryzom/client/src/r2/editor.cpp | 58 +++++++-------- .../data_common/r2/r2_ui_event_handlers.lua | 2 +- 14 files changed, 165 insertions(+), 93 deletions(-) diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h index cacec7931..50896b30c 100644 --- a/code/nel/include/nel/gui/lua_helper.h +++ b/code/nel/include/nel/gui/lua_helper.h @@ -266,8 +266,16 @@ namespace NLGUI const char *getTableStringValue(const char *name, const char *defaultValue= NULL); // pushing value onto the stack void push(bool value); - void push(lua_Number value); - void push(lua_Integer value); + void push(float value); + void push(double value); + void push(uint8 value); + void push(uint16 value); + void push(uint32 value); + void push(uint64 value); + void push(sint8 value); + void push(sint16 value); + void push(sint32 value); + void push(sint64 value); void push(const char *str); void push(const char *str, int length); void push(const std::string &str); diff --git a/code/nel/include/nel/gui/lua_helper_inline.h b/code/nel/include/nel/gui/lua_helper_inline.h index eadce7eaa..68721cfaa 100644 --- a/code/nel/include/nel/gui/lua_helper_inline.h +++ b/code/nel/include/nel/gui/lua_helper_inline.h @@ -322,19 +322,83 @@ inline void CLuaState::push(bool value) } //================================================================================ -inline void CLuaState::push(lua_Number value) +inline void CLuaState::push(float value) { //H_AUTO(Lua_CLuaState_push) nlverify( lua_checkstack(_State, 1) ); - lua_pushnumber(_State, value); + lua_pushnumber(_State, (lua_Number)value); } //================================================================================ -inline void CLuaState::push(lua_Integer value) +inline void CLuaState::push(double value) { //H_AUTO(Lua_CLuaState_push) nlverify( lua_checkstack(_State, 1) ); - lua_pushinteger(_State, value); + lua_pushnumber(_State, (lua_Number)value); +} + +//================================================================================ +inline void CLuaState::push(uint8 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); +} + +//================================================================================ +inline void CLuaState::push(uint16 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); +} + +//================================================================================ +inline void CLuaState::push(uint32 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); +} + +//================================================================================ +inline void CLuaState::push(uint64 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); +} + +//================================================================================ +inline void CLuaState::push(sint8 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); +} + +//================================================================================ +inline void CLuaState::push(sint16 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); +} + +//================================================================================ +inline void CLuaState::push(sint32 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); +} + +//================================================================================ +inline void CLuaState::push(sint64 value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, (lua_Integer)value); } //================================================================================ diff --git a/code/nel/src/gui/dbgroup_combo_box.cpp b/code/nel/src/gui/dbgroup_combo_box.cpp index b594fea9a..dd30957b8 100644 --- a/code/nel/src/gui/dbgroup_combo_box.cpp +++ b/code/nel/src/gui/dbgroup_combo_box.cpp @@ -598,7 +598,7 @@ namespace NLGUI { const char *funcName = "getNumTexts"; CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push((double) getNumTexts()); + ls.push(getNumTexts()); return 1; } diff --git a/code/nel/src/gui/group_list.cpp b/code/nel/src/gui/group_list.cpp index 0b4fbf8b8..e75f8787e 100644 --- a/code/nel/src/gui/group_list.cpp +++ b/code/nel/src/gui/group_list.cpp @@ -1145,7 +1145,7 @@ namespace NLGUI { CLuaIHM::checkArgCount(ls, "getElementIndex", 1); CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - ls.push((double) getElementIndex(viewBase)); + ls.push(getElementIndex(viewBase)); return 1; } diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp index e41af0ad9..381623e20 100644 --- a/code/nel/src/gui/group_menu.cpp +++ b/code/nel/src/gui/group_menu.cpp @@ -1702,7 +1702,7 @@ namespace NLGUI int CGroupSubMenu::luaGetNumLine(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getNumLine", 0); - ls.push((double) getNumLine()); + ls.push(getNumLine()); return 1; } @@ -1744,7 +1744,7 @@ namespace NLGUI const char *funcName = "getLineFromId"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - ls.push((double) getLineFromId(ls.toString(1))); + ls.push(getLineFromId(ls.toString(1))); return 1; } diff --git a/code/nel/src/gui/group_tree.cpp b/code/nel/src/gui/group_tree.cpp index b0b936215..1b80ee84b 100644 --- a/code/nel/src/gui/group_tree.cpp +++ b/code/nel/src/gui/group_tree.cpp @@ -1836,7 +1836,7 @@ namespace NLGUI { const char *funcName = "CGroupTree::SNode::luaGetNumChildren"; CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push((double) Children.size()); + ls.push((uint)Children.size()); return 1; } diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 1fc404fec..6318bf61a 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -1173,7 +1173,7 @@ namespace NLGUI int CInterfaceGroup::luaGetNumGroups(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getNumGroups", 0); - ls.push((double) _ChildrenGroups.size()); + ls.push((uint)_ChildrenGroups.size()); return 1; } diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 9c2dfc1ac..f1c91c4a4 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -944,8 +944,8 @@ namespace NLGUI CLuaIHM::checkArgCount(ls, "getWindowSize", 0); uint32 w, h; CViewRenderer::getInstance()->getScreenSize(w, h); - ls.push((double) w); - ls.push((double) h); + ls.push(w); + ls.push(h); return 2; } @@ -976,8 +976,8 @@ namespace NLGUI CIFile fs(CPath::lookup(textureName).c_str()); bitmap.load(fs); - ls.push((double) bitmap.getWidth()); - ls.push((double) bitmap.getHeight()); + ls.push(bitmap.getWidth()); + ls.push(bitmap.getHeight()); return 2; } @@ -1100,7 +1100,7 @@ namespace NLGUI ls.push(value.getBool()); break; case CInterfaceExprValue::Integer: - ls.push((double)value.getInteger()); + ls.push(value.getInteger()); break; case CInterfaceExprValue::Double: ls.push(value.getDouble()); @@ -1363,7 +1363,7 @@ namespace NLGUI ls.newTable(); for(uint k = 0; k < files.size(); ++k) { - ls.push((double) k); + ls.push(k); ls.push(files[k]); ls.setTable(-3); } @@ -1383,10 +1383,10 @@ namespace NLGUI ls.push( (reflectedObject.*(property.GetMethod.GetBool))() ); break; case CReflectedProperty::SInt32: - ls.push( (lua_Integer)(reflectedObject.*(property.GetMethod.GetSInt32))() ); + ls.push( (reflectedObject.*(property.GetMethod.GetSInt32))() ); break; case CReflectedProperty::Float: - ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetFloat))() ); + ls.push( (reflectedObject.*(property.GetMethod.GetFloat))() ); break; case CReflectedProperty::String: ls.push( (reflectedObject.*(property.GetMethod.GetString))() ); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 8d913a1a8..f6385cb53 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -141,7 +141,7 @@ int CDBCtrlSheet::luaGetHpBuff(CLuaState &ls) uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - ls.push((double)itemInfo.HpBuff); + ls.push(itemInfo.HpBuff); return 1; } @@ -153,7 +153,7 @@ int CDBCtrlSheet::luaGetSapBuff(CLuaState &ls) uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - ls.push((double)itemInfo.SapBuff); + ls.push(itemInfo.SapBuff); return 1; } @@ -165,7 +165,7 @@ int CDBCtrlSheet::luaGetFocusBuff(CLuaState &ls) uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - ls.push((double)itemInfo.FocusBuff); + ls.push(itemInfo.FocusBuff); return 1; } @@ -177,7 +177,7 @@ int CDBCtrlSheet::luaGetStaBuff(CLuaState &ls) uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - ls.push((double)itemInfo.StaBuff); + ls.push(itemInfo.StaBuff); return 1; } 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 db8018762..34339e53a 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -316,7 +316,7 @@ int CLuaIHMRyzom::luaClientCfgIndex(CLuaState &ls) switch(v->Type) { case CConfigFile::CVar::T_REAL: - ls.push((double) v->asDouble()); + ls.push(v->asDouble()); return 1; break; case CConfigFile::CVar::T_STRING: @@ -325,7 +325,7 @@ int CLuaIHMRyzom::luaClientCfgIndex(CLuaState &ls) break; default: // handle both T_INT && T_BOOL case CConfigFile::CVar::T_INT: - ls.push((double) v->asInt()); + ls.push(v->asInt()); return 1; break; } @@ -1010,7 +1010,7 @@ int CLuaIHMRyzom::hideAllNonSavableWindows(CLuaState &/* ls */) int CLuaIHMRyzom::getDesktopIndex(CLuaState &ls) { //H_AUTO(Lua_CLuaIHM_getDesktopIndex) - ls.push((double) CInterfaceManager::getInstance()->getMode()); + ls.push(CInterfaceManager::getInstance()->getMode()); return 1; } @@ -1050,7 +1050,7 @@ int CLuaIHMRyzom::getCharSlot(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_getCharSlot) const char *funcName = "getCharSlot"; CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push(double(PlayerSelectedSlot)); + ls.push(PlayerSelectedSlot); return 1; } @@ -1060,7 +1060,7 @@ int CLuaIHMRyzom::getServerSeason(CLuaState &ls) const char *funcName = "getServerSeason"; CLuaIHM::checkArgCount(ls, funcName, 0); extern uint8 ServerSeasonValue; - ls.push((double) ServerSeasonValue); + ls.push(ServerSeasonValue); return 1; } @@ -1069,7 +1069,7 @@ int CLuaIHMRyzom::computeCurrSeason(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_computeCurrSeason) const char *funcName = "computeCurrSeason"; CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push((double) (::computeCurrSeason() + 1)); + ls.push((sint)(::computeCurrSeason() + 1)); return 1; } @@ -1078,7 +1078,7 @@ int CLuaIHMRyzom::getAutoSeason(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_getAutoSeason) const char *funcName = "getAutoSeason"; CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push((double) (StartupSeason + 1)); + ls.push((sint)(StartupSeason + 1)); return 1; } @@ -1151,7 +1151,7 @@ int CLuaIHMRyzom::getPlayerDirection(CLuaState &ls) int CLuaIHMRyzom::getPlayerGender(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerGender", 0); - ls.push((lua_Integer)(UserEntity->getGender())); + ls.push((uint8)UserEntity->getGender()); return 1; } @@ -1217,7 +1217,7 @@ int CLuaIHMRyzom::getTargetGender(CLuaState &ls) CLuaIHM::checkArgCount(ls, "getTargetGender", 0); CCharacterCL* target = (CCharacterCL*)getTargetEntity(); if (!target) return (int)GSGENDER::unknown; - ls.push((lua_Integer)(target->getGender())); + ls.push((uint8)target->getGender()); return 1; } @@ -1358,7 +1358,7 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls) if (sheetId.buildSheetId(sheedtName)) { uint32 idx = CVisualSlotManager::getInstance()->sheet2Index(sheetId, (SLOTTYPE::EVisualSlot)slotId); - ls.push((lua_Integer)idx); + ls.push(idx); } else return 0; @@ -1369,7 +1369,7 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls) int CLuaIHMRyzom::getTargetSlot(CLuaState &ls) { uint32 slot = (uint32)getTargetSlotNr(); - ls.push((lua_Integer)slot); + ls.push(slot); return 1; } @@ -1401,7 +1401,7 @@ int CLuaIHMRyzom::getClientCfgVar(CLuaState &ls) switch(v->Type) { case CConfigFile::CVar::T_REAL: - ls.push((double) v->asDouble()); + ls.push(v->asDouble()); return 1; break; case CConfigFile::CVar::T_STRING: @@ -1410,7 +1410,7 @@ int CLuaIHMRyzom::getClientCfgVar(CLuaState &ls) break; default: // handle both T_INT && T_BOOL case CConfigFile::CVar::T_INT: - ls.push((double) v->asInt()); + ls.push(v->asInt()); return 1; break; } @@ -1521,9 +1521,9 @@ int CLuaIHMRyzom::getIndexInDB(CLuaState &ls) // get the index in db if(pCS) - ls.push((double)pCS->getIndexInDB()); + ls.push(pCS->getIndexInDB()); else - ls.push(0.0); + ls.push((sint)0); return 1; } @@ -1791,7 +1791,7 @@ int CLuaIHMRyzom::getIslandId(CLuaState &ls) CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance(); uint32 id = scenarioEntryPoints.getIslandId(ls.toString(1)); - ls.push((double)id); + ls.push(id); return 1; } diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index d214d1150..c7e5e380b 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -4563,14 +4563,14 @@ int CSPhraseComAdpater::luaGetCastTime(CLuaState &ls) { if (Phrase.Bricks.empty()) { - ls.push((double) 0); + ls.push(0.0); return 1; } CSPhraseManager *pPM = CSPhraseManager::getInstance(); float castTime; float castTimeMalus; pPM->getPhraseCastTime(Phrase, pPM->getTotalActionMalus(Phrase), castTime, castTimeMalus); - ls.push((double) (castTime + castTimeMalus)); + ls.push(castTime + castTimeMalus); return 1; } @@ -4579,14 +4579,14 @@ int CSPhraseComAdpater::luaGetCastRange(CLuaState &ls) { if (Phrase.Bricks.empty()) { - ls.push((double) 0); + ls.push((sint)0); return 1; } CSPhraseManager *pPM = CSPhraseManager::getInstance(); sint range; - sint rangeMalus; + sint rangeMalus; pPM->getPhraseMagicRange(this->Phrase, pPM->getTotalActionMalus(Phrase), range, rangeMalus); - ls.push((double) (range + rangeMalus)); + ls.push(range + rangeMalus); return 1; } @@ -4595,14 +4595,14 @@ int CSPhraseComAdpater::luaGetHpCost(CLuaState &ls) { if (Phrase.Bricks.empty()) { - ls.push((double) 0); + ls.push((sint)0); return 1; } CSPhraseManager *pPM = CSPhraseManager::getInstance(); sint hpCost; sint hpCostMalus; pPM->getPhraseHpCost(this->Phrase, pPM->getTotalActionMalus(Phrase), hpCost, hpCostMalus); - ls.push((double) (hpCost + hpCostMalus)); + ls.push(hpCost + hpCostMalus); return 1; } @@ -4611,14 +4611,14 @@ int CSPhraseComAdpater::luaGetSapCost(CLuaState &ls) { if (Phrase.Bricks.empty()) { - ls.push((double) 0); + ls.push((sint)0); return 1; } CSPhraseManager *pPM = CSPhraseManager::getInstance(); sint sapCost; sint sapCostMalus; pPM->getPhraseSapCost(this->Phrase, pPM->getTotalActionMalus(Phrase), sapCost, sapCostMalus); - ls.push((double) (sapCost + sapCostMalus)); + ls.push(sapCost + sapCostMalus); return 1; } @@ -4627,11 +4627,11 @@ int CSPhraseComAdpater::luaGetSuccessRate(CLuaState &ls) { if (Phrase.Bricks.empty()) { - ls.push((double) 0); + ls.push((sint)0); return 1; } CSPhraseManager *pPM = CSPhraseManager::getInstance(); ; - ls.push((double) pPM->getPhraseSuccessRate(this->Phrase)); + ls.push(pPM->getPhraseSuccessRate(this->Phrase)); return 1; } @@ -4641,14 +4641,14 @@ int CSPhraseComAdpater::luaGetFocusCost(CLuaState &ls) { if (Phrase.Bricks.empty()) { - ls.push((double) 0); + ls.push((sint)0); return 1; } CSPhraseManager *pPM = CSPhraseManager::getInstance(); sint focusCost; sint focusCostMalus; pPM->getPhraseFocusCost(this->Phrase, pPM->getTotalActionMalus(Phrase), focusCost, focusCostMalus); - ls.push((double) (focusCost + focusCostMalus)); + ls.push(focusCost + focusCostMalus); return 1; } @@ -4657,14 +4657,14 @@ int CSPhraseComAdpater::luaGetStaCost(CLuaState &ls) { if (Phrase.Bricks.empty()) { - ls.push((double) 0); + ls.push((sint)0); return 1; } CSPhraseManager *pPM = CSPhraseManager::getInstance(); sint staCost; sint staCostMalus; pPM->getPhraseStaCost(this->Phrase, pPM->getTotalActionMalus(Phrase), staCost, staCostMalus); - ls.push((double) (staCost + staCostMalus)); + ls.push(staCost + staCostMalus); return 1; } @@ -4756,7 +4756,7 @@ int CSPhraseComAdpater::luaIsPowerPhrase(CLuaState &ls) int CSPhraseComAdpater::luaGetRegenTime(CLuaState &ls) { CSPhraseManager *pPM = CSPhraseManager::getInstance(); - ls.push((double) pPM->getRegenTime(Phrase)); + ls.push((sint)pPM->getRegenTime(Phrase)); return 1; } @@ -4764,7 +4764,7 @@ int CSPhraseComAdpater::luaGetRegenTime(CLuaState &ls) int CSPhraseComAdpater::luaGetTotalRegenTime(CLuaState &ls) { CSPhraseManager *pPM = CSPhraseManager::getInstance(); - ls.push((double) pPM->getTotalRegenTime(Phrase)); + ls.push((sint)pPM->getTotalRegenTime(Phrase)); return 1; } @@ -4772,7 +4772,7 @@ int CSPhraseComAdpater::luaGetTotalRegenTime(CLuaState &ls) int CSPhraseComAdpater::luaGetPowerDisableTime(CLuaState &ls) { CSPhraseManager *pPM = CSPhraseManager::getInstance(); - ls.push((double) pPM->getPowerDisableTime(Phrase)); + ls.push((sint)pPM->getPowerDisableTime(Phrase)); return 1; } diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index 5d00cdc2b..45916dd7d 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -1869,8 +1869,8 @@ void CClientEditionModule::onKicked(NLNET::IModuleProxy * /* sender */, uint32 t { //H_AUTO(R2_CClientEditionModule_onKicked) - R2::getEditor().getLua().push((double)timeBeforeDisconnection); - R2::getEditor().getLua().push((bool)mustKick); + R2::getEditor().getLua().push(timeBeforeDisconnection); + R2::getEditor().getLua().push(mustKick); R2::getEditor().callEnvFunc( "onKicked", 2, 0); } @@ -2019,9 +2019,9 @@ void CClientEditionModule::onAnimationModePlayConnected(NLNET::IModuleProxy * /* void CClientEditionModule::scheduleStartAct(NLNET::IModuleProxy * /* sender */, uint32 errorId, uint32 actId, uint32 nbSeconds) { //H_AUTO(R2_CClientEditionModule_scheduleStartAct) - R2::getEditor().getLua().push((double)errorId); - R2::getEditor().getLua().push((double)actId); - R2::getEditor().getLua().push((double)nbSeconds); + R2::getEditor().getLua().push(errorId); + R2::getEditor().getLua().push(actId); + R2::getEditor().getLua().push(nbSeconds); R2::getEditor().callEnvFunc( "onScheduleStartAct", 3, 0); } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index cbc7ba19d..dae1a5fb8 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -1009,9 +1009,9 @@ int CEditor::luaSnapPosToGround(CLuaState &ls) if (gpos.InstanceId != -1) { CVector snappedPos = GR->getGlobalPosition(gpos); - ls.push((double) snappedPos.x); - ls.push((double) snappedPos.y); - ls.push((double) snappedPos.z); + ls.push(snappedPos.x); + ls.push(snappedPos.y); + ls.push(snappedPos.z); return 3; } else @@ -1025,9 +1025,9 @@ int CEditor::luaSnapPosToGround(CLuaState &ls) CVector inter; if (CTool::computeWorldMapIntersection((float) ls.toNumber(2), (float) ls.toNumber(3), inter) != CTool::NoIntersection) { - ls.push((double) inter.x); - ls.push((double) inter.y); - ls.push((double) inter.z); + ls.push(inter.x); + ls.push(inter.y); + ls.push(inter.z); return 3; } else @@ -1045,9 +1045,9 @@ int CEditor::luaGetUserEntityPosition(CLuaState &ls) CHECK_EDITOR const char *funcName = "getUserEntityPosition"; CLuaIHM::checkArgCount(ls, funcName, 1); - ls.push((double) UserEntity->pos().x); - ls.push((double) UserEntity->pos().y); - ls.push((double) UserEntity->pos().z); + ls.push(UserEntity->pos().x); + ls.push(UserEntity->pos().y); + ls.push(UserEntity->pos().z); return 3; } @@ -1058,8 +1058,8 @@ int CEditor::luaGetUserEntityFront(CLuaState &ls) CHECK_EDITOR const char *funcName = "getUserEntityPosition"; CLuaIHM::checkArgCount(ls, funcName, 1); - ls.push((double) UserEntity->front().x); - ls.push((double) UserEntity->front().y); + ls.push(UserEntity->front().x); + ls.push(UserEntity->front().y); return 2; } @@ -1443,7 +1443,7 @@ int CEditor::luaIsScenarioUpdating(CLuaState &ls) //H_AUTO(R2_CEditor_luaIsScenarioUpdating) const char *funcName = "isScenarioUpdating"; CLuaIHM::checkArgCount(ls, funcName, 1); // method with no args - ls.push( (double)getEditor()._UpdatingScenario ); + ls.push( getEditor()._UpdatingScenario ); return 1; } @@ -1487,9 +1487,9 @@ int CEditor::luaIsValidPosition(CLuaState &ls) if (gpos.InstanceId != -1) { CVector snappedPos = GR->getGlobalPosition(gpos); - ls.push((double) snappedPos.x); - ls.push((double) snappedPos.y); - ls.push((double) snappedPos.z); + ls.push(snappedPos.x); + ls.push(snappedPos.y); + ls.push(snappedPos.z); return 3; } else @@ -1503,9 +1503,9 @@ int CEditor::luaIsValidPosition(CLuaState &ls) CVector inter; if (CTool::computeWorldMapIntersection((float) ls.toNumber(2), (float) ls.toNumber(3), inter) != CTool::NoIntersection) { - ls.push((double) inter.x); - ls.push((double) inter.y); - ls.push((double) inter.z); + ls.push(inter.x); + ls.push(inter.y); + ls.push(inter.z); } @@ -1540,7 +1540,7 @@ int CEditor::luaGetUserEntityName(CLuaState &ls) if (UserEntity) { ucstring name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; - ls.push( std::string( name.toUtf8() ) ); + ls.push( name.toUtf8() ); } else { @@ -1928,7 +1928,7 @@ void CInstanceObserverLua::onAttrModified(CInstance &instance, const std::string if (_Receiver["onAttrModified"].isNil()) return; // no-op if not handled getEditor().projectInLua(instance.getObjectTable()); getEditor().getLua().push(attrName); - getEditor().getLua().push((double) attrIndex); + getEditor().getLua().push(attrIndex); _Receiver.callMethodByNameNoThrow("onAttrModified", 3, 0); } @@ -1942,7 +1942,7 @@ int CEditor::luaAddInstanceObserver(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); // instance id CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); // receiver CLuaObject receiver(ls); // pop the receiver - ls.push((double) getEditor().addInstanceObserver(ls.toString(2), new CInstanceObserverLua(receiver))); + ls.push(getEditor().addInstanceObserver(ls.toString(2), new CInstanceObserverLua(receiver))); return 1; } @@ -2214,11 +2214,11 @@ void CEditor::setUIMode(uint8 mode) if (_ForceDesktopReset[mode]) { // force to call reset when reloading the ui - getLua().push((double) mode); + getLua().push(mode); callEnvMethod("resetDesktop", 1, 0); _ForceDesktopReset[mode] = false; } - getLua().push((double) mode); + getLua().push(mode); callEnvMethod("onChangeDesktop", 1, 0); } @@ -3293,11 +3293,11 @@ void CEditor::initObjectProjectionMetatable() sint32 index = obj->getParent()->findIndex(obj); if (obj->getParent()->getKey(index).empty()) { - ls.push((double) index); + ls.push(index); } else { - ls.push((double) -1); + ls.push(-1); } return 1; } @@ -3311,7 +3311,7 @@ void CEditor::initObjectProjectionMetatable() { if (obj->isTable()) { - ls.push((double) obj->getSize()); + ls.push(obj->getSize()); } else { @@ -3509,7 +3509,7 @@ void CEditor::initObjectProjectionMetatable() } if (obj->getKey(index).empty()) { - ls.push((double) index); + ls.push(index); } else { @@ -5423,7 +5423,7 @@ bool CEditor::verifyRoomLeft(uint aiCost, uint staticCost) if (aiCost) { CLuaStackChecker lsc(&ls); - getEditor().getLua().push((lua_Integer)aiCost); + getEditor().getLua().push(aiCost); callEnvMethod("checkAiQuota", 1, 1); if (!ls.isBoolean(-1)) { @@ -5437,7 +5437,7 @@ bool CEditor::verifyRoomLeft(uint aiCost, uint staticCost) if (staticCost) { CLuaStackChecker lsc(&ls); - getEditor().getLua().push((lua_Integer)staticCost); + getEditor().getLua().push(staticCost); callEnvMethod("checkStaticQuota", 1, 1); if (!ls.isBoolean(-1)) { diff --git a/code/ryzom/common/data_common/r2/r2_ui_event_handlers.lua b/code/ryzom/common/data_common/r2/r2_ui_event_handlers.lua index 431d89eae..f043db5d9 100644 --- a/code/ryzom/common/data_common/r2/r2_ui_event_handlers.lua +++ b/code/ryzom/common/data_common/r2/r2_ui_event_handlers.lua @@ -832,7 +832,7 @@ function r2:onActChanged(previousAct, currentAct) -- update the select bar r2.SelectBar:touch() - if r2:isScenarioUpdating() == 1 then + if r2:isScenarioUpdating() then return end