This commit is contained in:
kaetemi 2014-09-15 16:59:12 +02:00
parent ca7c0e23f1
commit 34b1fa4e36
9 changed files with 71 additions and 59 deletions

View file

@ -1132,7 +1132,7 @@ void CFarTP::disconnectFromPreviousShard()
*/ */
NetMngr.reinit(); NetMngr.reinit();
if (isIngame()) if (isIngame() && !isReselectingChar())
{ {
nlinfo("FarTP: calling EntitiesMngr.reinit()"); nlinfo("FarTP: calling EntitiesMngr.reinit()");
EntitiesMngr.reinit(); EntitiesMngr.reinit();

View file

@ -1931,6 +1931,7 @@ void CLuaIHMRyzom::rawDebugInfo(const std::string &dbg)
#endif #endif
pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg)); pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg));
} }
nldebug("LUA: '%s'", dbg.c_str());
} }

View file

@ -1116,7 +1116,7 @@ function userComponentManager:export(list, refX, refY, refZ)
messageBox(i18n.get("uiR2EDInvalidName")) messageBox(i18n.get("uiR2EDInvalidName"))
return return
end end
if string.find(form.ComponentFileName, '\.lua', -4) == nil then if string.find(form.ComponentFileName, '.lua', -4) == nil then
form.ComponentFileName = form.ComponentFileName .. ".lua" form.ComponentFileName = form.ComponentFileName .. ".lua"
end end
local refPosition = form.RefPosition local refPosition = form.RefPosition

View file

@ -140,7 +140,8 @@ end
function assert(cond) function assert(cond)
if not cond then if not cond then
rawDebugInfo(colorTag(255, 0, 255) .. "ASSERTION FAILED !! ") -- rawDebugInfo(colorTag(255, 0, 255) .. "ASSERTION FAILED !! ")
rawDebugInfo("@{FOFF}ASSERTION FAILED !! ")
dumpCallStack(2); dumpCallStack(2);
error("") error("")
end end

View file

@ -1679,7 +1679,7 @@ Logic.translateChatSequences = function (context, hlComponent, behavior, rtNpcGr
event.Name = "activity_sequence_changed" event.Name = "activity_sequence_changed"
table.insert(context.RtAct.Events, event) table.insert(context.RtAct.Events, event)
local rtInitChatStep = r2.Translator.createAction("code", "oldChatStepVar = -1;\n" .. Logic.chatStepVar .." = 0;\n()setTimer(1, " ..Logic.chatTimerId .. ")\;\n") local rtInitChatStep = r2.Translator.createAction("code", "oldChatStepVar = -1;\n" .. Logic.chatStepVar .." = 0;\n()setTimer(1, " ..Logic.chatTimerId .. ");\n")
rtInitChatStep.Name = "init_chat_step" rtInitChatStep.Name = "init_chat_step"
table.insert(context.RtAct.Actions, rtInitChatStep) table.insert(context.RtAct.Actions, rtInitChatStep)
table.insert(event.ActionsId, rtInitChatStep.Id) table.insert(event.ActionsId, rtInitChatStep.Id)

View file

@ -32,9 +32,8 @@ end
-- extension to table library : remove all content of a table without deleting the table object -- extension to table library : remove all content of a table without deleting the table object
function table.clear(tbl) function table.clear(tbl)
while next(tbl) do while next(tbl) do
tbl[next(tbl)] = nil table.remove(tbl, next(tbl))
end end
table.setn(tbl, 0)
end end
------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------
@ -175,6 +174,17 @@ function strify(str)
return [["]] .. tostring(str) .. [["]] return [["]] .. tostring(str) .. [["]]
end end
-------------------------------------------------------------------------------------------------
-- enclose a string by double quotes
function strifyXml(str)
strxml = string.gsub(str, ">", ">")
strxml = string.gsub(strxml, "<", "&lt;")
strxml = string.gsub(strxml, "&", "&amp;")
strxml = string.gsub(strxml, "'", "&apos;")
strxml = string.gsub(strxml, '"', "&quot;")
return [["]] .. tostring(strxml) .. [["]]
end
------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------
-- snap a position to ground, returning the z snapped coordinate -- snap a position to ground, returning the z snapped coordinate
function r2:snapZToGround(x, y) function r2:snapZToGround(x, y)

View file

@ -328,7 +328,7 @@ end
local function saveScenarioOnChange(formInstance) local function saveScenarioOnChange(formInstance)
r2.print(formInstance.Name) r2.print(formInstance.Name)
local name = string.gsub(formInstance.Name, "[\\\/\:\*\?\"\<\>\|]", "_") local name = string.gsub(formInstance.Name, "[\\/:*?\"<>|]", "_")
if name ~= formInstance.Name then if name ~= formInstance.Name then
fromInstance.Name = name fromInstance.Name = name
formInstance.Modified = true formInstance.Modified = true

View file

@ -47,13 +47,13 @@ function r2:buildEditBox(prop, textRef, entryType, multiLine, maxNumChars, onCha
bg_texture="grey_40.tga" bg_texture="grey_40.tga"
onchange="lua" onchange_params="getUICaller():setupDisplayText(); getUICaller():find('edit_text'):updateCoords(); getUICaller():getEnclosingContainer().Env.updateSize()" onchange="lua" onchange_params="getUICaller():setupDisplayText(); getUICaller():find('edit_text'):updateCoords(); getUICaller():getEnclosingContainer().Env.updateSize()"
onenter="lua" on_focus_lost="lua"]] .. onenter="lua" on_focus_lost="lua"]] ..
[[ id= ]] .. strify(prop.Name) .. [[ id= ]] .. strifyXml(prop.Name) ..
[[ text_ref = ]] .. strify(textRef) .. [[ text_ref = ]] .. strifyXml(textRef) ..
[[ entry_type = ]] .. strify(entryType) .. [[ entry_type = ]] .. strifyXml(entryType) ..
[[ multi_line = ]] .. strify(multiLine) .. [[ multi_line = ]] .. strifyXml(multiLine) ..
[[ max_num_chars = ]] .. strify(maxNumChars) .. [[ max_num_chars = ]] .. strifyXml(maxNumChars) ..
[[ params = ]] .. strify(onChangeAction) .. [[ params = ]] .. strifyXml(onChangeAction) ..
[[ on_focus_lost_params = ]] .. strify(onFocusLostAction) .. [[ on_focus_lost_params = ]] .. strifyXml(onFocusLostAction) ..
"/>" "/>"
return result return result
end end
@ -73,13 +73,13 @@ end
-- bg_texture="grey_40.tga" -- bg_texture="grey_40.tga"
-- onchange="lua" onchange_params="getUICaller():setupDisplayText(); getUICaller():find('edit_text'):updateCoords(); getUICaller():getEnclosingContainer().Env.updateSize()" -- onchange="lua" onchange_params="getUICaller():setupDisplayText(); getUICaller():find('edit_text'):updateCoords(); getUICaller():getEnclosingContainer().Env.updateSize()"
-- onenter="lua" on_focus_lost="lua"]] .. -- onenter="lua" on_focus_lost="lua"]] ..
-- [[ id= ]] .. strify(prop.Name) .. -- [[ id= ]] .. strifyXml(prop.Name) ..
-- [[ text_ref = ]] .. strify(textRef) .. -- [[ text_ref = ]] .. strifyXml(textRef) ..
-- [[ entry_type = ]] .. strify(entryType) .. -- [[ entry_type = ]] .. strifyXml(entryType) ..
-- [[ multi_line = ]] .. strify(multiLine) .. -- [[ multi_line = ]] .. strifyXml(multiLine) ..
-- [[ max_num_chars = ]] .. strify(maxNumChars) .. -- [[ max_num_chars = ]] .. strifyXml(maxNumChars) ..
-- [[ params = ]] .. strify(onChangeAction) .. -- [[ params = ]] .. strifyXml(onChangeAction) ..
-- [[ on_focus_lost_params = ]] .. strify(onChangeAction) .. -- [[ on_focus_lost_params = ]] .. strifyXml(onChangeAction) ..
-- [[ /> -- [[ />
-- --
-- --
@ -1043,7 +1043,7 @@ r2.WidgetStyles.Number =
width1 = tmp width1 = tmp
end end
local part0 = [[<TD width=]] .. strify(width0) .. [[ ignore_max_width="true" ignore_min_width="true" bgcolor="80 80 80 127" height="0" align="left" valign="middle" id= "l_]] .. prop.Name .. [[" > ]] local part0 = [[<TD width=]] .. strifyXml(width0) .. [[ ignore_max_width="true" ignore_min_width="true" bgcolor="80 80 80 127" height="0" align="left" valign="middle" id= "l_]] .. prop.Name .. [[" > ]]
local tooltipTextId, tooltipTextIdFound = buildPropTooltipName(className, prop.Name) local tooltipTextId, tooltipTextIdFound = buildPropTooltipName(className, prop.Name)
@ -1051,7 +1051,7 @@ r2.WidgetStyles.Number =
tooltip_parent="win" tooltip_parent="win"
tooltip_posref="auto" tooltip_posref="auto"
instant_help="true" instant_help="true"
tooltip=]] .. strify(tooltipTextId) .. ">" tooltip=]] .. strifyXml(tooltipTextId) .. ">"
part0 = part0 .. buildCoverAllButton(prop) part0 = part0 .. buildCoverAllButton(prop)
local color = "255 255 255 255" local color = "255 255 255 255"
@ -1066,10 +1066,10 @@ r2.WidgetStyles.Number =
end end
part0 = part0 .. [[ <view type="text" y="-2" sizeref="w" over_extend_view_text="true" over_extend_parent_rect="true"]] .. part0 = part0 .. [[ <view type="text" y="-2" sizeref="w" over_extend_view_text="true" over_extend_parent_rect="true"]] ..
[[ id = ]] .. strify(prop.Name .. "_Caption") .. [[ id = ]] .. strifyXml(prop.Name .. "_Caption") ..
[[ hardtext = ]] .. strify(hardText) .. [[ hardtext = ]] .. strifyXml(hardText) ..
[[ color = ]] .. strify(color) .. [[ color = ]] .. strifyXml(color) ..
[[ global_color=]] .. strify(globalColor) .. [[ fontsize="12" shadow="true" auto_clamp="true"/> ]] [[ global_color=]] .. strifyXml(globalColor) .. [[ fontsize="12" shadow="true" auto_clamp="true"/> ]]
part0 = part0 .. "</group>" part0 = part0 .. "</group>"
part0 = part0 .. "</TD>" part0 = part0 .. "</TD>"
@ -1086,7 +1086,7 @@ r2.WidgetStyles.Number =
-- --
local widgetXml = local widgetXml =
string.format([[ string.format([[
<group posref="TL TL" x="4" y="3" sizeref="w" w="-4" child_resize_h="true" child_resize_hmargin="3" id= ]] .. strify(prop.Name) .. ">" .. [[ <group posref="TL TL" x="4" y="3" sizeref="w" w="-4" child_resize_h="true" child_resize_hmargin="3" id= ]] .. strifyXml(prop.Name) .. ">" .. [[
<view type="bitmap" id="bk" posref="BL BL" scale="true" y="4" sizeref="w" h="2" texture="W_line_hor2.tga" /> <view type="bitmap" id="bk" posref="BL BL" scale="true" y="4" sizeref="w" h="2" texture="W_line_hor2.tga" />
<ctrl type="scroll" id="c" posparent="bk" posref="MM MM" x="0" y="-1" sizeref="w" h="12" <ctrl type="scroll" id="c" posparent="bk" posref="MM MM" x="0" y="-1" sizeref="w" h="12"
vertical="false" align="L" tracksize="12" vertical="false" align="L" tracksize="12"
@ -1136,14 +1136,14 @@ r2.WidgetStyles.Number =
local result = local result =
[[ [[
<group type="combo_box" sizeref="w" w="-2" x="2" y="0" child_resize_h="true" child_resize_hmargin="10" linked_to_db="false" posref="TL TL" id=]] <group type="combo_box" sizeref="w" w="-2" x="2" y="0" child_resize_h="true" child_resize_hmargin="10" linked_to_db="false" posref="TL TL" id=]]
.. strify(prop.Name) .. .. strifyXml(prop.Name) ..
string.format([[ on_change="lua" on_change_params="if getUICaller().parent.Env.Locked ~= true then r2:requestSetObjectProperty('%s', getUICaller().selection) end"]], prop.Name) .. string.format([[ on_change="lua" on_change_params="if getUICaller().parent.Env.Locked ~= true then r2:requestSetObjectProperty('%s', getUICaller().selection) end"]], prop.Name) ..
">" ">"
result = result .. [[<instance template="combo_box_def1" />]] result = result .. [[<instance template="combo_box_def1" />]]
-- append enumerated values -- append enumerated values
for k, v in pairs(prop.Enum) do for k, v in pairs(prop.Enum) do
result = result .. [[<combo_text name="]] .. tostring(v) .. [[" />]] result = result .. [[<combo_text name=]] .. strifyXml(tostring(v)) .. [[ />]]
end end
result = result .. "</group>" result = result .. "</group>"
return result, setter return result, setter
@ -1201,10 +1201,10 @@ function r2:createPropertyXmlTable(props, className, posparent, posref, x, y, wi
result = result .. value result = result .. value
end end
add([[<group type="table" sizeparent="parent"]] .. add([[<group type="table" sizeparent="parent"]] ..
[[ posparent= ]] .. strify(posparent) .. [[ posparent= ]] .. strifyXml(posparent) ..
[[ posref= ]] .. strify(posref) .. [[ posref= ]] .. strifyXml(posref) ..
[[ x= ]] .. strify(x) .. [[ x= ]] .. strifyXml(x) ..
[[ y= ]] .. strify(y) .. [[ y= ]] .. strifyXml(y) ..
[[ id="prop_table" sizeref="w" width="100%" border="0" bgcolor="0 0 0 255" [[ id="prop_table" sizeref="w" width="100%" border="0" bgcolor="0 0 0 255"
cellspacing="1" cellspacing="1"
cellpadding="0" cellpadding="0"
@ -1249,18 +1249,18 @@ function r2:createPropertyXmlTable(props, className, posparent, posref, x, y, wi
local part0 local part0
if not captionXmlDesc then if not captionXmlDesc then
part0 = [[<TD width=]] .. strify(width0) .. [[ ignore_max_width="true" ignore_min_width="true" bgcolor="80 80 80 127" height="0" align="left" valign="middle" id= "l_]] .. prop.Name .. [[" > ]] part0 = [[<TD width=]] .. strifyXml(width0) .. [[ ignore_max_width="true" ignore_min_width="true" bgcolor="80 80 80 127" height="0" align="left" valign="middle" id= "l_]] .. prop.Name .. [[" > ]]
part0 = part0 .. [[<group id="caption_group" sizeref="w" child_resize_h="true" posref="ML ML" part0 = part0 .. [[<group id="caption_group" sizeref="w" child_resize_h="true" posref="ML ML"
tooltip_parent="win" tooltip_parent="win"
tooltip_posref="auto" tooltip_posref="auto"
instant_help="true" instant_help="true"
tooltip=]] .. strify(tooltipTextId) .. ">" tooltip=]] .. strifyXml(tooltipTextId) .. ">"
part0 = part0 .. [[ <view type="text" y="-2" sizeref="w" over_extend_view_text="true" over_extend_parent_rect="true"]] .. part0 = part0 .. [[ <view type="text" y="-2" sizeref="w" over_extend_view_text="true" over_extend_parent_rect="true"]] ..
[[ id = ]] .. strify(prop.Name .. "_Caption") .. [[ id = ]] .. strifyXml(prop.Name .. "_Caption") ..
[[ hardtext = ]] .. strify(hardText) .. [[ hardtext = ]] .. strifyXml(hardText) ..
[[ color = ]] .. strify(color) .. [[ color = ]] .. strifyXml(color) ..
[[ global_color=]] .. strify(globalColor) .. [[ fontsize="12" shadow="true" auto_clamp="true"/> ]] [[ global_color=]] .. strifyXml(globalColor) .. [[ fontsize="12" shadow="true" auto_clamp="true"/> ]]
part0 = part0 .. "</group>" part0 = part0 .. "</group>"
part0 = part0 .. "</TD>" part0 = part0 .. "</TD>"
else else
@ -1268,13 +1268,13 @@ function r2:createPropertyXmlTable(props, className, posparent, posref, x, y, wi
end end
-- build the widget -- build the widget
local part1 = [[<TD width=]] .. strify(width1) .. [[ ignore_max_width="true" ignore_min_width="true" bgcolor="64 64 64 127" height="0" align="left" valign="middle" id= "r_]] .. prop.Name .. [[" > ]] local part1 = [[<TD width=]] .. strifyXml(width1) .. [[ ignore_max_width="true" ignore_min_width="true" bgcolor="64 64 64 127" height="0" align="left" valign="middle" id= "r_]] .. prop.Name .. [[" > ]]
part1 = part1 .. [[<group id="widget_group" sizeref="w" child_resize_h="true" posref="ML ML" part1 = part1 .. [[<group id="widget_group" sizeref="w" child_resize_h="true" posref="ML ML"
tooltip_parent="win" tooltip_parent="win"
tooltip_posref="auto" tooltip_posref="auto"
tooltip_posref_alt="TL TR" tooltip_posref_alt="TL TR"
instant_help="true" instant_help="true"
tooltip=]] .. strify(tooltipTextId) .. ">" tooltip=]] .. strifyXml(tooltipTextId) .. ">"
part1 = part1 .. widgetXmlDesc .. [[</group></TD>]] part1 = part1 .. widgetXmlDesc .. [[</group></TD>]]
if invertWidget then if invertWidget then
@ -1397,15 +1397,15 @@ function r2:buildPropRolloutXml(caption, id, posparent, posref, props, className
-- add the rollout bar -- add the rollout bar
if not isForm then if not isForm then
result = result .. result = result ..
[[ <instance template="rollout_bar" caption=]] .. strify(caption) .. [[ <instance template="rollout_bar" caption=]] .. strifyXml(caption) ..
[[ color=]] .. strify(color) .. [[ color=]] .. strifyXml(color) ..
[[ global_color=]] .. strify(globalColor) .. [[ global_color=]] .. strifyXml(globalColor) ..
[[ content_name="prop_table"/> ]] [[ content_name="prop_table"/> ]]
else else
result = result .. result = result ..
[[ <instance template="form_bar" caption=]] .. strify(caption) .. [[ <instance template="form_bar" caption=]] .. strifyXml(caption) ..
[[ color=]] .. strify(color) .. [[ color=]] .. strifyXml(color) ..
[[ global_color=]] .. strify(globalColor) .. [[ global_color=]] .. strifyXml(globalColor) ..
[[ /> ]] [[ /> ]]
end end
@ -1475,9 +1475,9 @@ function r2:buildPropertySheetXml(class, className, id, title, isForm)
if isForm then -- for forms, closing the form is equivalent to clicking on 'cancel' if isForm then -- for forms, closing the form is equivalent to clicking on 'cancel'
add(' resizer="true" ') add(' resizer="true" ')
local w = defaulting(class.Width, 500) local w = defaulting(class.Width, 500)
add(' pop_min_w=' .. strify(w)) add(' pop_min_w=' .. strifyXml(w))
add(' pop_max_w=' .. strify(w)) add(' pop_max_w=' .. strifyXml(w))
add(' w=' .. strify(w)) add(' w=' .. strifyXml(w))
local cancelCode = local cancelCode =
[[ local form = getUICaller() [[ local form = getUICaller()
if form.Env.Choice == nil then if form.Env.Choice == nil then
@ -1518,7 +1518,7 @@ function r2:buildPropertySheetXml(class, className, id, title, isForm)
add([[id=]] .. strify(id) .. [[ add([[id=]] .. strifyXml(id) .. [[
>]]) >]])
@ -1647,7 +1647,7 @@ function r2:buildPropertySheetXml(class, className, id, title, isForm)
</group> <!-- enclosing --> </group> <!-- enclosing -->
</group> <!-- content --> </group> <!-- content -->
</group> </group>
<tree node=]] .. strify(id) .. [[ > <tree node=]] .. strifyXml(id) .. [[ >
</tree> </tree>
]]) ]])

View file

@ -36,7 +36,7 @@ UnitTest.testLoadAnimationScenarioUi = function()
end end
local filename = form.LoadScenario_Name local filename = form.LoadScenario_Name
if string.find(filename, '\.r2', -3) == nil then if string.find(filename, '.r2', -3) == nil then
local ui = r2:getForm("LoadScenario") local ui = r2:getForm("LoadScenario")
ui.active = true ui.active = true
@ -134,12 +134,12 @@ UnitTest.testLoadScenarioUi = function()
local ucName = ucstring() local ucName = ucstring()
ucName:fromUtf8(form.LoadScenario_Name) ucName:fromUtf8(form.LoadScenario_Name)
local filename = tostring(ucName) local filename = tostring(ucName)
if string.find(filename, '\.r2', -3) == nil then if string.find(filename, '.r2', -3) == nil then
messageBox(i18n.get("uiR2EDLoadScenario_InvalidFileName")) messageBox(i18n.get("uiR2EDLoadScenario_InvalidFileName"))
return return
end end
-- if string.find(filename, '\.r2', -3) == nil then -- if string.find(filename, '.r2', -3) == nil then
-- filename = form.Name .. ".r2" -- filename = form.Name .. ".r2"
-- end -- end
@ -206,7 +206,7 @@ function UnitTest.saveScenario(name, overwrite)
messageBox(i18n.get("uiR2EDInvalidName")) messageBox(i18n.get("uiR2EDInvalidName"))
return return
end end
if string.find(name, '\.r2', -3) == nil then if string.find(name, '.r2', -3) == nil then
name = name .. ".r2" name = name .. ".r2"
end end
-- update scenario name with the new name -- update scenario name with the new name
@ -1103,8 +1103,8 @@ end
function t5() function t5()
local toto = "&ezr_çà'_\\)d //:1' 2 éééà'..)à\/:*?\"<>|à)@4 58ftgsfdg\"\/:*?\"<>|" local toto = "&ezr_çà'_\\)d //:1' 2 éééà'..)à/:*?\"<>|à)@4 58ftgsfdg\"/:*?\"<>|"
toto = string.gsub(toto, "[\\\/\:\*\?\"\<\>\|]", "_") toto = string.gsub(toto, "[\\/:*?\"<>|]", "_")
end end