View Issue Details

IDProjectCategoryView StatusLast Update
0003025FSSCPscriptingpublic2014-03-29 02:11
Reporterniffiwan Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinux 
Product Version3.7.1 
Target Version3.7.2 
Summary0003025: LUA HookVar "MouseButton" reports invalid data
DescriptionThis HookVar (added in r10477) does not work correctly on Linux. The root cause is probably some difference in va_arg handling between the different compilers. Anyway, when hv.MouseButton is used in a LUA script random integers are returned, instead of the expected bit fields (i.e. MOUSE_* defines). Note that the return values are consistent while FSO is running, but they usually change the next time FSO is run.
Steps To ReproduceAdd a script like this:

data/tables/itbroke-sct.tbm

$On Mouse Released:
[
        ba.warning( hv.MouseButton )
]

Note the value is not any of:
#define MOUSE_LEFT_BUTTON (1<<0)
#define MOUSE_RIGHT_BUTTON (1<<1)
#define MOUSE_MIDDLE_BUTTON (1<<2)

(unless you're *super* lucky)
Additional InformationThis should fix the issue.

Note that the MouseButton HookVar is the 1st integer HookVar added to FSO (well, there are others but they are all commented out).

diff --git a/code/parse/scripting.cpp b/code/parse/scripting.cpp
index d2efbfc..1c3060f 100644
--- a/code/parse/scripting.cpp
+++ b/code/parse/scripting.cpp
@@ -670,6 +670,8 @@ void script_state::SetHookVar(char *name, char format, void *data)
                        {
                                if(format == 's')
                                        ade_set_args(LuaState, fmt, data);
+ else if (format == 'i')
+ ade_set_args(LuaState, fmt, *(int*)data);
                                else
                                        ade_set_args(LuaState, fmt, *(ade_odata*)data);
                        }
TagsNo tags attached.

Activities

niffiwan

2014-03-28 06:14

developer   ~0015689

Just needs some testing on Windows to ensure the proposed fix doesn't break anything.

m_m

2014-03-28 09:08

developer   ~0015690

I hate the C-style varargs for stuff like this...
Just tested it on Windows and it works fine.

niffiwan

2014-03-29 02:11

developer   ~0015692

Fix committed to trunk@10543.

Related Changesets

fs2open: trunk r10543

2014-03-28 21:16

niffiwan


Ported: N/A

Details Diff
Fix mantis 3025: pass lua HookVar integer data as an integer, not a struct Affected Issues
0003025
mod - /trunk/fs2_open/code/parse/scripting.cpp Diff File

Issue History

Date Modified Username Field Change
2014-03-28 06:12 niffiwan New Issue
2014-03-28 06:12 niffiwan Status new => assigned
2014-03-28 06:12 niffiwan Assigned To => niffiwan
2014-03-28 06:14 niffiwan Note Added: 0015689
2014-03-28 06:14 niffiwan Status assigned => feedback
2014-03-28 09:08 m_m Note Added: 0015690
2014-03-29 02:11 niffiwan Changeset attached => fs2open trunk r10543
2014-03-29 02:11 niffiwan Note Added: 0015692
2014-03-29 02:11 niffiwan Status feedback => assigned
2014-03-29 02:11 niffiwan Status assigned => resolved
2014-03-29 02:11 niffiwan Resolution open => fixed