Commit graph

3683 commits

Author SHA1 Message Date
Bill Currie
a6003ed08a Walk qfo alias chain for type size and alignment
While the basic type is stored in the alias type record, it's no good
for size or alignment as it will give incorrect results for complex
types.
2020-02-19 21:41:46 +09:00
Bill Currie
a0914e1ec8 Fix the typedef test case to actually work 2020-02-19 21:41:46 +09:00
Bill Currie
6a70d2e362 Give alias types a unique encoding
The encoding is used as the def name and it needs to be different than
the alias target or the linker throws it away as an external def.
2020-02-19 21:41:46 +09:00
Bill Currie
6bc803c72d Use correct encoding for alias types
I got confused which field was which.
2020-02-19 21:41:46 +09:00
Bill Currie
6bcc2c49ab Use helper functions for type checks
They hide the evil details of aliased types. More to come :/
2020-02-19 21:41:46 +09:00
Bill Currie
9610788dea Fix some more type aliasing issues
Getting there... (I knew this would be a big job)
2020-02-19 21:41:46 +09:00
Bill Currie
d50a27a045 Race down the alias chain before checking types
This takes care of some of the type aliasing issues.
2020-02-19 21:41:46 +09:00
Bill Currie
a5aba6c8ac Implement type aliasing
The separate types are in the file, but there are multiple issues
2020-02-19 21:41:46 +09:00
Bill Currie
2f18364364 Start work on encoding typedef chains 2020-02-19 21:41:46 +09:00
Bill Currie
adb7f5d601 Quieten the test script build rules 2020-02-19 21:41:46 +09:00
Bill Currie
b00c866c4e Allow casting between string and pointer types 2020-02-19 21:41:46 +09:00
Bill Currie
7a315b4a89 Fix storage class for for-loop declarations
Getting "i redeclared" when i was declared in a for loop in two
different functions was a tad unexpected.
2020-02-19 21:41:46 +09:00
Bill Currie
67e183c8b6 Put the guts of qwaq's reflection code into ruamoko 2020-02-19 21:41:46 +09:00
Bill Currie
4c40928112 Remove what appears to be a redundant check
It was long wrong anyway as it checked past the end of the function's
parameters, which caused a segfault when calling varargs functions with
no formal parameters.
2020-02-19 02:53:38 +09:00
Bill Currie
a65d6bce09 Fix a warning that got through
I forgot to compile test in optimized...
2020-02-19 02:43:27 +09:00
Bill Currie
bd6dcafdc8 Replace system defines/includes with qfcc's
Right now, it probably works only with modern gcc.
2020-02-19 02:35:09 +09:00
Bill Currie
2d52da9c0d Fix segfault in unlimited params 2020-02-19 02:35:09 +09:00
Bill Currie
c61d0b6ff0 Allow unlimited parameters in function declarations
However, definitions are still limited to 8 parameters. This allows
processing of C headers for type information.
2020-02-19 02:35:09 +09:00
Bill Currie
ee228504aa Fix self-referenced enum declarations
eg:
typedef enum foo {
    bar = 1,
    baz = bar,
} foo;
2020-02-19 02:35:09 +09:00
Bill Currie
7a399c956b Encode function parameter alignment
The encoding is 3:5 giving 3 bits for alignment (log2) and 5 bits for
size, with alignment in the 3 most significant bits. This keeps the
format backwards compatible as until doubles were added, all types were
aligned to 1 word which gets encoded as 0, and the size is unaffected.
2020-02-16 17:10:43 +09:00
Bill Currie
1bc08c59f6 Add tests for %%
double fails due to qfcc aligning double param locals, but the engine
not doing so.
2020-02-16 17:02:38 +09:00
Bill Currie
1a9510834a Add a missed opcode conversion for %% 2020-02-16 12:10:09 +09:00
Bill Currie
9d2d33fa50 Implement %% (true modulo) support in qfcc
However, it's not quite working yet
2020-02-16 11:57:58 +09:00
Bill Currie
4269c8cb07 Rename the mod instruction to rem
Because % really implements remainder rather than true modulo, and I
plan on adding %% to implement true modulo.
2020-02-16 11:04:30 +09:00
Bill Currie
db9996023f Add some tests for double comparison
More testing the engine than the compiler, but hey :)
2020-02-15 23:49:12 +09:00
Bill Currie
14acfad7c4 Fix incorrect placement of far data
All the care in aligning things was undone by not updating the
calculations of the pointers.
2020-02-15 23:49:12 +09:00
Bill Currie
1985b6d4fd Avoid creating a struct temp for ivar struct return
This fixed the uninitialized temp warning in HUD.r. The problem was
caused by the flow analyzer not being able to detect that the struct
temp was being initialized by the move statement due to the address of
the temp being in a pointer temp. While it would be good to use a
constant pointer for the address of the struct temp or improving the
flow analyzer to track actual data, avoiding the temp in the first place
results in nicer code as it removes a move statement.
2020-02-15 23:49:12 +09:00
Bill Currie
9c996df7b4 Add a test case for the uninit temp in HUD.r 2020-02-15 23:49:12 +09:00
Bill Currie
7bfa0f7a92 Allow pragmas to have arguments
It does mean only one pragma per line, but that's not such a big deal.
2020-02-15 23:49:12 +09:00
Bill Currie
91f5023681 Promote bugs to internal errors
Mostly so I can catch them in test cases
2020-02-15 23:49:12 +09:00
Bill Currie
344d429134 Test array initializer double demotions
Turns out array inits are very strict about types (bug?).
2020-02-15 23:49:12 +09:00
Bill Currie
6ce99afa5b Catch double demotion in global initializers
Local initializers are handled by regular assignments
2020-02-15 23:49:12 +09:00
Bill Currie
c5ce18591f Catch and warn demotion of double in assignments 2020-02-15 23:49:12 +09:00
Bill Currie
08ca59d0df Add tests for double demotion 2020-02-15 23:49:12 +09:00
Bill Currie
4bf37b274b Ensure double is not in zero or param structs for v6 2020-02-15 23:49:12 +09:00
Bill Currie
be30a0eb19 Fix missing alignment init on zero and param types 2020-02-15 23:49:12 +09:00
Bill Currie
3e651b43f8 Handle aliased values when emitting statements
With this, cast address initializers work. I have to wonder if the alias
value short-circuit was legacy from long before the rewrite, as it was
quite trivial to handle in the back-end.
2020-02-15 23:49:12 +09:00
Bill Currie
e4eb793fb3 Treat aliased values as constant
One step closer to cast address initializers working.
2020-02-15 23:49:12 +09:00
Bill Currie
ce9902baed Don't short-circuit aliased values
Not sure why I thought it was a good idea as it turns out this is why
cast pointer initializers were being lost.
2020-02-15 23:49:12 +09:00
Bill Currie
3257e7145b Add failing global init test too 2020-02-15 23:49:12 +09:00
Bill Currie
4caa875442 Finish up alignment tests and add address cast
It turns out that initializing a local int with a pointer cast doesn't
work.
2020-02-15 23:49:12 +09:00
Bill Currie
a4a57b6ffd Implement aligned allocations 2020-02-15 23:49:12 +09:00
Bill Currie
293f10211a Start on alignment test
Currently fails (deliberately, WIP)
2020-02-15 23:49:12 +09:00
Bill Currie
0542daacdf Create more double related tests
Including catching warnings :) (yay -Werror)
2020-02-15 23:49:12 +09:00
Bill Currie
7e09a94469 Fix "casts" between signed and unsigned int 2020-02-15 23:49:12 +09:00
Bill Currie
5d8d805b60 Fix test for single overload functions
All functions are stored in the overload functions table, even those
that are never explicitly overloaded, but only explicitly overloaded
functions (those with @overload) use the type-qualified naming.
2020-02-15 23:49:12 +09:00
Bill Currie
533fb8acc9 Implement double constants 2020-02-15 23:49:12 +09:00
Bill Currie
2cd62fe01b Fix several double-related bug
float is promoted to double through ... for non-v6 code.
PR_Sprintf has custom param access via P_*, messed up doubles.
2020-02-15 23:49:12 +09:00
Bill Currie
eb7f825158 Test for full-float % 2020-02-15 23:49:12 +09:00
Bill Currie
8920c59515 Find @override functions even when there's only one 2020-02-15 23:49:12 +09:00
Bill Currie
df7c08a010 Add support for doubles to Ruamoko
Only as scalars, I still need to think about what to do for vectors and
quaternions due to param size issues. Also, doubles are not yet
guaranteed to be correctly aligned.
2020-02-15 23:49:12 +09:00
Bill Currie
13b608f40c Don't truncat float % float
This allows full usage, eg, x % pi, but otherwise maintains
compatibility with integer %
2020-02-15 23:49:12 +09:00
Bill Currie
16f8dca72e Align local and far data spaces
I plan on adding doubles, and so it's necessary to ensure that attempts
to align doubles in local or far data spaces remain aligned after final
linking.
2020-02-15 23:49:12 +09:00
Bill Currie
197f856a30 Fix incorrect scalar/quaternion division
It's just not possible.
2020-02-15 23:49:12 +09:00
Bill Currie
9248e8cf01 Update for doxygen 1.8.16 2020-02-11 15:22:42 +09:00
Bill Currie
9d09d65d9a Clean up some export stuff
While it's not there yet, the eventual goal is to support multiple
models in the one blend file, so per-object settings is a requirement.
2019-08-20 16:52:43 +09:00
Bill Currie
c14e5623ad Get the mdl frames script property working
Maybe late 2.78+, blender added the ability to use any ID type in
PointerProperty, which is just what I wanted for the frames script.
2019-08-16 22:34:45 +09:00
Bill Currie
839d90981d Clean up a few last things for blender 2.80
Many many thanks to Aleksander Marhall for the initial work.
2019-08-16 22:32:37 +09:00
khreathor
008b5a4d2c Import/Export fixes after some Blender 2.8 API changes 2019-08-16 21:38:29 +09:00
khreathor
11e5f39fdc Fix for the export error when there is no Shape Keys available 2019-08-16 21:38:29 +09:00
khreathor
36da80c0d0 Export proper frame names 2019-08-16 21:38:29 +09:00
khreathor
33d114c09e Set playback/animation range to start from frame 1 2019-08-16 21:38:29 +09:00
khreathor
ff5f9f1831 Add "empty" skin during export for models with no materials or texture nodes 2019-08-16 21:38:29 +09:00
khreathor
3913febace MDL properties in object panel are back 2019-08-16 21:38:29 +09:00
khreathor
31fa7a81ef Fix for single skin being marked as skingroup 2019-08-16 21:38:29 +09:00
khreathor
94c3c8c2cb Skingroup image export order based on texture node position (height) in shader editor. Nodes with higher position are exported first. 2019-08-16 21:38:29 +09:00
khreathor
4f29f57e77 Proper node positioning after import 2019-08-16 21:38:29 +09:00
khreathor
a13c382969 Skingroup images import order fix 2019-08-16 21:38:29 +09:00
khreathor
4d1f05186b Skingroups export added 2019-08-16 21:38:29 +09:00
khreathor
17e76149a1 Adjust playback range on import, to fit mdl's animation length 2019-08-16 21:38:29 +09:00
khreathor
66fe862a87 Import skingroups as separate materials with skins as textures 2019-08-16 21:38:29 +09:00
khreathor
ae86790e6c Initial Blender 2.8 changes - it works, now it's time for improvements 2019-08-16 21:38:29 +09:00
khreathor
8112c4e8b6 Moved MDL settings from Object tab to export options/presets 2019-08-16 21:38:29 +09:00
khreathor
90a707f7f9 Export animation range selected with start/end playback range in Timeline Editor 2019-08-16 21:38:29 +09:00
Bill Currie
c3fa78ef4d Include test for 2d vector expressions 2019-07-06 14:49:28 +09:00
Bill Currie
8caf2eb584 Mark some new functions as pure 2019-06-27 21:37:48 +09:00
Bill Currie
a5ee58cebb Support 2d vector expressions
[x, y] expands to [x, y, 0] (for now, might add a 2d vector type).
2019-06-18 11:54:45 +09:00
Bill Currie
83fac13a0c Fix debug line numbers for vector expressions 2019-06-18 11:53:58 +09:00
Bill Currie
b37c331e76 Catch taking size of null type
This should help catch similar errors in the future.
2019-06-18 10:39:17 +09:00
Bill Currie
0f1f477e64 Set up temp aliases correctly
Fixes vector expressions as sub-expresses. I really don't know why I did
the temp alias setup that way.
2019-06-18 10:38:19 +09:00
Bill Currie
fc50376297 Fix a minor error check mistake 2019-06-18 08:54:18 +09:00
Bill Currie
fe73547f43 Update alias type sameness check
This one seems to be fairly robust. Fixes alias being used to cast
pointers (maybe a better way, but this works for now).
2019-06-18 08:53:05 +09:00
Bill Currie
f7825fe7cf Print types properly in pointer value expressions 2019-06-18 00:22:24 +09:00
Bill Currie
b996fb7aa4 Make operand->type actual type instead of low-level
And clean up the resulting mess. This fixes struct copy, but uncovers
another bug :/
2019-06-17 23:38:34 +09:00
Bill Currie
e0c8285f07 Extend nested struct test to cover struct copy
Fails :P
2019-06-17 22:57:40 +09:00
Bill Currie
dd52b7fea1 Merge aliased alias expressions
This comes up when accessing struct fields nested in another struct.
Fixes the nested struct fields test.
2019-06-17 22:48:42 +09:00
Bill Currie
e9c24dbf1c Test case for accessing nested struct fields
Currently fails.
2019-06-17 22:47:44 +09:00
Bill Currie
ec128ffeee Leave a FIXME for daglabel_t.live 2019-06-16 19:24:19 +09:00
Bill Currie
d6d3027411 Mark the correct operand as live
This fixes vecexpr (and possibly other cases).
2019-06-16 19:21:02 +09:00
Bill Currie
6e21c3ae2e Treat func statements similarly to flow statements
func statements need their operands marked live like flow statements do
because usage is more indirect.
2019-06-16 19:20:21 +09:00
Bill Currie
db4a7a139e Use the alias code when making vars live
Not sure the live forcing flag is needed anymore (need to test).
2019-06-16 19:17:45 +09:00
Bill Currie
2977c145d0 Clean up dag live alias code a little
Mainly, this makes it possible to reuse the alias code.
2019-06-16 19:17:01 +09:00
Bill Currie
82b334e919 Number dot dumps to help identify order 2019-06-16 19:12:18 +09:00
Bill Currie
c40f4194e9 Use tempop_visit_all for flow and dags
Fixes t3 of vecexpr, but t2 is broken (lost first assignment).
2019-06-16 16:56:39 +09:00
Bill Currie
3c4903245a Fix some curly space 2019-06-16 16:55:54 +09:00
Bill Currie
bc271d8a02 Add tempop_visit_all
Works the same as def_visit_all, but for temp operands.
2019-06-16 16:52:49 +09:00
Bill Currie
fa69aeef0f Improve handling of temp aliases
This makes all tests pass when not optimizing. More work needs to be
done in dags.
2019-06-12 00:37:02 +09:00
Bill Currie
b18a744288 Use offset alias expressions
They are not quite working yet as the operand generator does not use the
offset yet.
2019-06-10 23:55:16 +09:00
Bill Currie
cc27949a34 Ensure pointer values always have a type
The dags generator was creating a pointer value with no type which
caused print_statement to segfault.
2019-06-10 23:52:39 +09:00
Bill Currie
ee1f5f9478 Add support for binary alias expressions
Doesn't quite work yet.
2019-06-10 23:48:58 +09:00
Bill Currie
913b9f52e0 Add an offset alias expression
This should make dealing with def elements (vector etc) easier.
2019-06-10 18:13:28 +09:00
Bill Currie
efdfc7436f Move ev_types into types.[ch]
No wonder I couldn't find it the other day...
2019-06-10 18:04:25 +09:00
Bill Currie
08ab42fc15 Handle vector expressions as sub-expressions
Now my little game builds again :)
2019-06-10 15:50:35 +09:00
Bill Currie
49ed4310fd Fix assigning int to enum or enum to int
Or float, for v6 progs.
2019-06-10 08:46:40 +09:00
Bill Currie
83fb588727 Support vector/quaternion division by float
Implemented via v*(1/f) or q*(1/f) to give CSE a chance to optimize the
division if necessary as otherwise the engine would have to divide every
time.
2019-06-10 08:44:36 +09:00
Bill Currie
7dc1a0640a Delay creating actual enum symbols
In order to keep enumerator type and enum type the same, the values need
to have their type set after the enum type is finalized, and then the
appropriate symbols created in the parent scope. This fixes the infinite
recursion when assigning an enum value to its own type.
2019-06-10 07:44:23 +09:00
Bill Currie
f81484a068 Test compiling enums
It turns out the enumerator type and enum type wind up with different
instances of the same type (due to the way type chaining works). This
results in infinite recursion in assign_expr and check_types_compatible.
2019-06-10 07:17:41 +09:00
Bill Currie
ef4ad52239 Make binary_expr fold constants
This is where constant folding should have happened all along. While
unary_expr should fold constants too, it seems to already try to do so
and it's a bit much of a mess to clean up right now.
2019-06-10 00:36:13 +09:00
Bill Currie
bf0543f7fb Be paranoid about temp var sizes
Prevents array index errors.
2019-06-10 00:19:48 +09:00
Bill Currie
28a2b96800 Implement automatic array sizing from initializer 2019-06-09 23:11:38 +09:00
Bill Currie
00f12263ca Fix casting arrays to pointers 2019-06-09 22:55:38 +09:00
Bill Currie
3196bcc851 Allow fold_constants to handle some math identities
Such as x*0 -> 0, x*1 -> x, x+0 ->x, etc.
2019-06-09 22:34:23 +09:00
Bill Currie
c98d1ff08c Document some problems with nil
While he's a pretty cool character in HZD, he seems to have some
identity problems when in a compiler.
2019-06-09 22:29:51 +09:00
Bill Currie
439cd15620 Do type promotion for short
fold_constants used to do this when it was overly aggressive. Fixes the
ICE when accessing an array in a struct via a pointer.
2019-06-09 22:27:53 +09:00
Bill Currie
227ac46ffe Clean up array expression processing
And make sure constants are folded since fold_constants is no longer
recursive.
2019-06-09 22:25:55 +09:00
Bill Currie
f70801fa52 Add a test for accessing an array in a struct
That's accessed via a pointer. Whee. However, at this stage, the problem
is really a promotion issue for short -> integer.
2019-06-09 21:44:58 +09:00
Bill Currie
e46a44d9c6 Update TODO 2019-06-09 21:37:46 +09:00
Bill Currie
6253623e9b Remove some weird dereference code
It appears to have been an attempt at optimizing dereferences, but it
instead just utterly mangled them.
2019-06-09 21:37:46 +09:00
Bill Currie
f49303e774 Emit code for address expressions
It helps if the necessary code is actually emitted in the first place.
2019-06-09 21:37:46 +09:00
Bill Currie
8cef85e5de Cast scalar types when necessary on assignment
This fixes type promotion errors that broke some tests.
2019-06-09 20:12:50 +09:00
Bill Currie
e849c2d1ce Mark block expr result as rvalue when used as one
At least for return. There may be other cases that need it, but this
fixes comma-expr.r (minus int->float promotion issues).
2019-06-09 19:29:21 +09:00
Bill Currie
d9c9686288 Make initialized globals non-constant
This is for modern code. Traditional code still treats initialized
globals as constant and nosave. This will make a bit of a mess of
modern code that expects traditional behavior.
2019-06-09 19:23:23 +09:00
Bill Currie
b7b6a89b91 Simplify fold_constants
While this does break automatic type promotion, it does stop
fold_constants recursing through complex expressions: only the top level
expression needs to be folded, and then only if both sides are actually
constant.
2019-06-09 19:20:35 +09:00
Bill Currie
2ee36e8b99 Rename qfot_type_t.ty to meta
When I did up a ruamoko implementation of a type encoding dumper, I
named the field meta, which feels much better than ty.
2019-06-09 18:10:07 +09:00
Bill Currie
f093516962 Move qfo type encoding structs
This makes them available to the gamecode VM, and thus the debugger.
2019-06-09 18:07:58 +09:00
Bill Currie
7fce68649a Implement comma expressions
Doesn't quite work (attempt to suppress warning for return a = 3, 5;
failed).
2019-06-09 16:56:20 +09:00
Bill Currie
689d1ad3ec Remove some debug prints 2019-06-09 16:45:01 +09:00
Bill Currie
33c2eb430f Stop bison complaining about %expect
And make sure warnings get fixed.
2019-06-09 16:19:27 +09:00
Bill Currie
1db600548e Fix for decl test scope issue 2019-06-09 13:55:07 +09:00
Bill Currie
ec89149b29 Build for loop decl inits correctly
The multiple expressions are chained together and evaluate in left to
right order.
2019-06-09 13:54:03 +09:00
Bill Currie
d29ea55826 Add a test for for loop declarations
I think the compiler segfaulting indicates a test failure.
2019-06-09 13:02:36 +09:00
Bill Currie
625e767684 Update qf dependency stuff for recent automake
Not sure just what version of automake broke things, but I do remember
having a bad time getting the dependencies to work in the first place.
At least now they should be more reliable (until automake changes
things).
2019-06-09 13:00:55 +09:00
Bill Currie
5bd3c8c985 Allow variable declarations in for loops
Matches C, C++ and C#
2019-06-08 21:52:17 +09:00
Bill Currie
be4c3a82a2 Detect redefinitions of structs and unions
While the redefinition was being detected, it was misreported as the tag
being wrong, and on the wrong line, too.
2019-06-08 19:25:25 +09:00
Bill Currie
f2102187b9 Clean up emit_protocol_list
Now it uses emit_structure, which will make it easier should things go
wrong.
2019-06-08 19:23:49 +09:00
Bill Currie
6acbdcb3e5 Correct a typo 2019-06-08 19:23:10 +09:00
Bill Currie
df0316bb13 Clean up some comment FIXMEs 2019-06-08 19:22:29 +09:00
Bill Currie
e217bdd55f Assign vector expressions to a temp for return
Rather than direct to .return, allowing return of vector expressions
with function calls without trashing the vector.
2019-06-08 13:36:03 +09:00
Bill Currie
ebab6574b9 Allow taking the address of a temporary variable 2019-06-08 13:35:47 +09:00
Bill Currie
e27da9c7db Avoid folding constants in assign_expr
This prevents fold_constants from complaining about attempts to take
the address of a vector.
2019-06-08 13:31:30 +09:00
Bill Currie
398e1cf83a Use output file as base for dot files
Ensures the output goes not go into the source directory when using a
separate build tree.
2019-06-08 13:30:06 +09:00
Bill Currie
3327127e36 Fix a typo in a comment 2019-06-08 13:28:29 +09:00
Bill Currie
4ef4a7e955 Start work on simple names in symbol tables
I don't remember what the goal was (stopped working on it eight months
ago), but some possibilities include:
 - better handling of nil (have trouble with assigning into struts)
 - automatic forward declarations ala C# and jai (I was watching vids
   about jai at the time)
 - something for pascal
 - simply that the default symbol type should not be var (in which case,
   goal accomplished)
2019-06-06 07:01:44 +09:00
Bill Currie
7e31704ebe Be more informative for pass by value size errors 2019-06-06 06:46:38 +09:00
Bill Currie
a5da8da1dc Be more informative for symbol type internal errors 2019-06-06 06:45:48 +09:00
Bill Currie
d00a2ef82d Convert constant vector expressions in binary expressions
Fixes not being able to compare with eg [1, 2, 3]
2019-06-06 06:44:19 +09:00
Bill Currie
319ecfbbfa Create a usable dot for vector expressions
It leaves a lot to be desired, but it beats "FIXME".
2019-06-06 06:42:31 +09:00
Bill Currie
607ec3124e More dead code removal.
I have no idea why this hung around. It appears to be old array/struct
initialization.
2018-10-15 22:12:40 +09:00
Bill Currie
ff5c1cd4c2 Clean up redundant type parameter to initialize_def. 2018-10-15 22:11:20 +09:00
Bill Currie
1746ce3af5 Make int type name reflect its keyword.
Makes qc error messages make more sense.
2018-10-15 20:54:05 +09:00
Bill Currie
302934a1e4 Remove some dead code. 2018-10-15 20:52:46 +09:00
Bill Currie
2a2754e581 More ways to break qfcc :/ 2018-10-15 19:48:19 +09:00
Bill Currie
6c53be928b Support returning vector expressions.
Currently fails due to a scheduling problem when the vector expression
contains functions.
2018-10-13 23:32:53 +09:00
Bill Currie
aaab18c9a7 Nuke a dead field.
It looks like ex_temp_t.expr was never really used, and I have no idea
what I had intended (not surprising after ~17 years).
2018-10-13 12:07:50 +09:00
Bill Currie
2f2edae43b Make error, warning and notice give compiler file/line too.
But only when verbosity > 1 (-vv).
2018-10-13 09:31:00 +09:00
Bill Currie
4828934e50 Fix a equality check typo.
Fixes bad code generation when assigning to vector.x in a function with no
parameters and the vector is the first local var.
2018-10-12 23:39:05 +09:00
Bill Currie
78e0a8dc52 Support assigning non-constant vector expressions. 2018-10-12 22:05:17 +09:00
Bill Currie
e03dfa29b4 Clean up the module .ctor construction a little. 2018-10-12 21:09:36 +09:00
Bill Currie
f56d25cda6 Don't double print messages. 2018-10-12 20:46:45 +09:00
Bill Currie
668896aa82 More diagnostic improvements. 2018-10-12 16:01:11 +09:00
Bill Currie
71b3d30aa1 Make the ice a little more informative. 2018-10-12 14:51:39 +09:00
Bill Currie
f58c2fef5a Switch QF's quaterions from wxyz to xyzw.
After messing with SIMD stuff for a little, I think I now understand why
the industry went with xyzw instead of the mathematical wxyz. Anyway, this
will make for less pain in the future (assuming I got everything).
2018-10-12 14:33:55 +09:00
Bill Currie
b7aa5bb8fe Fix an oops messing up edict size. 2018-10-12 14:33:26 +09:00
Bill Currie
f8606ebab8 Fix a object file segfault when spaces have no data.
ie, don't attempt to copy memory from a null pointer (just copy the null
pointer).
2018-10-12 14:00:34 +09:00
Bill Currie
3bd9f96b07 Make internal error messages a little more helpful.
They now include the file and line of the compiler as well.
2018-10-12 13:57:59 +09:00
Bill Currie
3656cb966c Fix some bison deprecation warnings. 2018-10-12 09:32:49 +09:00
Bill Currie
3bc664811e Fix lost error count tracking. 2018-10-11 22:03:14 +09:00
Bill Currie
a096babb1f Duplicate memory when creating a qfo from progs.
Fixes some double-free bugs when linking after compiling.
2018-10-11 21:37:01 +09:00
Bill Currie
f673ab9c3d Fix misreporting of failed progs load. 2018-10-11 13:39:48 +09:00
Bill Currie
82809eb856 Simplify the call to PR_LoadProgsFile.
I've decided that setting pr.max_edicts and pr.zone_size as part of the
local progs initialization rather than in PR_LoadProgsFile makes more
sense. For one, it is unlikely for the limits to change every time progs is
reloaded. Also, they seem to be a property of the VM rather than the progs.
However, there is nothing stopping the caller from updating max_edicts and
zone_size every call.
2018-10-11 10:06:48 +09:00
Bill Currie
673b45be05 Add diagnostic hooks. 2018-10-09 12:46:13 +09:00
Bill Currie
d95c01be1a More defspace tests. 2018-10-09 12:45:26 +09:00
Bill Currie
34bcf7faab Do a pure/const/noreturn/format attribute pass.
I always wanted these, but as gcc now provides warnings for functions that
could do with such attributes, finding all the functions is much easier.
2018-10-09 12:42:21 +09:00
Bill Currie
05fd2d8cdd Start work on a unit test for defspace. 2018-09-09 22:37:09 +09:00
Bill Currie
3a4667318c Fix the qfcc test autodependencies. 2018-09-09 22:36:20 +09:00
Bill Currie
d1cb15664f Fix some spelling issues in a comment. 2018-09-09 22:34:24 +09:00
Bill Currie
71569b45c9 Pre-format diagnostic messages.
This will make it easier to hook diagnostics enabling unit tests.
2018-09-09 18:09:32 +09:00
Bill Currie
113e0d82ba Fix a signed comparison error.
Not sure how this fix got lost.
2018-09-09 16:48:19 +09:00
Bill Currie
aebd9288cd Force thread count to 1 when pthreads is unavailable.
Don't want the thread count being misreported.
2018-09-09 13:41:22 +09:00
Bill Currie
fa1514798b Print the number of threads used by qfvis. 2018-09-09 13:41:00 +09:00
Bill Currie
06ab36de3d Slight cleanup of winding allocation.
It seems gcc doesn't care if the & is present when calculating field
offsets, but it not being there bothered me very much and might as well use
our "standard" macro anyway.
2018-09-09 13:38:32 +09:00
Bill Currie
59e85b7d5e Fix a pile of dead assignments.
Some were actual bugs!
2018-09-08 22:23:57 +09:00
Bill Currie
59b04dbcca Make many qfo int fields unsigned.
I don't remember why I thought signed was a good idea, but unsigned does
make more sense for most fields.
2018-09-08 19:45:19 +09:00
Bill Currie
f75ff2d269 Fix some null argument issues. 2018-09-07 22:30:44 +09:00
Bill Currie
8f028b8a0d Fix some double frees. 2018-09-07 20:03:19 +09:00
Bill Currie
8fd5be0ee0 Fix a pile of sizeof goofs.
While scan-build wasn't what I was looking for, it has proven useful
anyway: many of the sizeof errors were just noise, but a few were actual
bugs (allocating too much or too little memory).
2018-09-07 20:00:57 +09:00
Bill Currie
b37b0180cb Actually do a test for triangle.r.
If the kahan triangle area method breaks, I did something wrong with qfcc's
handling of parentheses (ie, floating point math is not truly associative).
2018-08-23 20:52:32 +09:00
Bill Currie
1b9149ef31 Fix an argument passing error in test-harness.
It failed to pass the last argument to the ruamoko program being run.
2018-08-23 20:22:29 +09:00
Bill Currie
2fcda44ab0 Kill dag leaf nodes on assignment.
Fixes the failing swap test caused by a's original value being used (via t)
after being written.
2018-08-23 20:07:22 +09:00
Bill Currie
cb366dd825 Better flow dot dump "scripting".
Not sure I want to keep the statements in the live dump, but the system
is more flexible now.
2018-08-23 20:07:11 +09:00
Bill Currie
cdbdf3f0eb Make print_operand global. 2018-08-23 20:05:16 +09:00
Bill Currie
8b8b42bde2 Fix a typo in a comment. 2018-08-23 20:04:51 +09:00
Bill Currie
f250065003 Add tests for swapping vars and triangle area.
Triangle area was meant just to check Kahan's equation, but it found a
problem with swapping vars. swap.r currently fails.
2018-08-21 16:27:22 +09:00
Bill Currie
0f279cd3f0 Add a comment about fake statement numbers.
I had forgotten how they worked (not surprising after 6 years).
2018-08-21 15:57:51 +09:00
Bill Currie
1b84ea747c Dump statements during flow analysis. 2018-08-21 15:56:39 +09:00
Bill Currie
5ba13d759b Fix a FIXME.
Set of everything got added shortly after that FIXME was added, but I
forgot to fix it.
2018-08-21 15:56:03 +09:00
Bill Currie
fbdf560a7a Rename print_extra_live to print_flow_vars. 2018-08-21 15:55:11 +09:00
Bill Currie
5dbb7b6d4d Handle all modelgen commands.
Just in case someone ever adds models.qc to progs.src.
2018-08-20 00:11:02 +09:00
Bill Currie
027e76b4c9 Add a doc block to parse_cpp_line.
It took me too long to figure it out :P
2018-08-20 00:09:20 +09:00
Bill Currie
4f58429137 Fix an unhealthy pile of gcc 8 warnings.
While some of the warnings were merely annoying, some where actual bugs or
unearthed bugs in related code.
2018-08-20 00:05:00 +09:00
Bill Currie
81202d7b29 Add a shutdown builtin to qwaq. 2018-08-19 19:44:45 +09:00
Bill Currie
b795beb520 Add support for \? to qc strings.
And fix up the man page a bit.
2018-08-19 19:31:52 +09:00
Bill Currie
0de0eb2fc7 Fix a bunch of bit-rot. 2018-06-08 13:21:30 +09:00
Bill Currie
f522e58d53 Fix some blender warnings. 2018-06-08 12:45:57 +09:00
Bill Currie
2329fb1885 Fix some warnings and bitrot. 2016-10-25 00:10:30 +09:00
Bill Currie
932647bad3 Fix a segfault with switch on an undefined symbol.
Forgot to check if the test expression was not an error.
2016-01-10 13:41:49 +09:00
Bill Currie
bf40f0126e Convert vector expressions when passing parameters.
Calling a function with [vector stuff] caused an ICE.
2016-01-08 21:16:37 +09:00
Bill Currie
1061256c4f Add a missing expression type to dot_expr. 2016-01-08 21:15:47 +09:00
Bill Currie
431074d58f Update label destination when moving labels.
This fixes a segfault when optimizing the empty-body test. The label was
getting moved, but the statement block to which it pointed was not updated
and thus it pointed to dead data.
2016-01-07 21:24:29 +09:00
Bill Currie
d54ee6c8c3 Do not promote debug messages to warnings.
I think I copied the notice code for debug and forgot to edit the
promotion. Oops.
2016-01-07 20:08:07 +09:00
Bill Currie
6e65de251c Put qwaq's epoch back to 0.
4Gs causes a few problems at this stage. I really need to look into putting
long and double into qc.
2016-01-04 20:42:57 +09:00
Bill Currie
735fcf68d5 Clean up usage of va_copy.
AC_TYPE_VA_LIST is no longer necessary, and the code is easier to read.
2016-01-03 21:16:23 +09:00
Bill Currie
a54f3d9035 Shutdown some subsystems on exit.
This fixes the problem with X keyboard repeat not being restored.
2016-01-03 17:39:03 +09:00
Bill Currie
c71eccfb10 Remove MAX_THREADS.
This fixes a buffer overflow with more than 4 threads.
2015-08-14 10:57:51 +09:00
Bill Currie
2cd59c962c Rename qfcc's basename to file_basename.
Avoids naming conflicts with JohnnyonFlame's toolchain.
2014-01-31 12:22:11 +09:00
Bill Currie
3efb0c538f Separate file search from loading.
QFS_LoadFile (and its wrappers) now  take a file handle rather than a
path. This will make vpath usage a little cleaner to implement.
2014-01-28 16:22:05 +09:00
Bill Currie
6c0f271783 Fix some more automake warnings. 2013-11-24 13:26:12 +09:00
Bill Currie
f5501fbf24 Fix a pile of automake deprecation warnings.
s/INCLUDES/AM_CPPFLAGS/g

I <3 sed :)
2013-11-24 13:11:50 +09:00
Bill Currie
6996e7295a Add a getLine method to Script.
It returns the rest of the line (minus // style comments) as the token. I
needed it in another project but this is my central repository for
script.py.
2013-11-24 11:21:40 +09:00
Bill Currie
eeaf2bc43f Return None instead of False from parse_entity.
Don't remember how I found that one, but None makes much more sense.
2013-11-24 11:19:50 +09:00
Bill Currie
c88d1987a1 Add warnings for empty blocks in if/else/do.
Saw a discussion of such in #qc and that gcc implemented it. I realized it
would be pretty easy to detect and very useful (I've made such mistakes at
times).
2013-09-30 18:09:04 +09:00
Bill Currie
db460155e9 Fix multiple function calls in expressions. 2013-09-27 23:15:57 +09:00
Bill Currie
70d18ecfa1 Add a test for functions in binary expressions.
As expected, the binary_expr() cleanup broke multiple function calls in a
single expression.
2013-09-27 23:15:57 +09:00
Bill Currie
4bc40b3917 Rewrite binary_expr().
It is now in its own file and uses table lookups to check for valid type
and operator combinations, and also the resulting type of the expression.

This probably breaks multiple function calls in the one expression.
2013-09-27 23:15:57 +09:00
Bill Currie
ec98954dfc Remove the small struct optimization.
It might cause trouble for the binary_expr() cleanup.
2013-09-27 23:15:57 +09:00
Bill Currie
3295370328 Expose and use field_expr().
This may cause problems later on, but it is needed for the binary_expr()
cleanup.
2013-09-27 23:15:57 +09:00
Bill Currie
ca9693d9cd Expose convert_from_bool(). 2013-09-27 23:15:57 +09:00
Bill Currie
b66cbeeb57 Run fold_constants on comparison operands.
This is a bit of a workaround to ensure the operands have their types
setup correctly. Really, binary_expr needs to handle expression types
properly.

This fixes the bogus error for comparing the result of pointer subtraction
with an integer.
2013-09-27 23:15:57 +09:00
Bill Currie
c13f2c2c23 Fix the support for [s, v] for quaterions. 2013-09-27 23:15:57 +09:00
Bill Currie
7f50333b2c Add support for constant [] vector expressions. 2013-09-27 23:15:57 +09:00
Bill Currie
7a7a685105 Add support for actual vector expressions.
Currently, they can represent either vectors or quaternions, and the
quaternions can be in either [s, v] form or [w, x, y, z] form.

Many things will not actual work yet as the vector expression needs to be
converted into the appropriate form for assigning the elements to the
components of the "vector" type.
2013-09-27 23:15:57 +09:00
Bill Currie
2572811bf4 Add support for quaternion.w/x/y/z.
It's sometimes more useful to have direct access to each individual
component of the imaginary part of the quaternion, and then for
consistency, alias w and s.
2013-09-27 23:15:57 +09:00
Bill Currie
a6cdc8735a Start implementing vec = [x,y,z].
This is a nice feature found in fteqcc (also a bit of a challenge from
Spike). Getting bison to accept the new expression required rewriting the
state expression grammar, so this is mostly for the state expression. A
test to ensure the state expression doesn't break is included.
2013-09-27 23:15:56 +09:00
Bill Currie
35de42aeac Catch bogus comparison types.
This fixes an ICE when trying to compare a function with a float.
2013-09-27 23:15:56 +09:00
Bill Currie
03fb47d7ba Fix some sizeof goofs.
Yay for continually improving gcc warnings :)
2013-09-26 17:45:30 +09:00
Bill Currie
16d899ace5 Remove the string:string concatentation TODO item.
I think it may have been for compatibility with a certain qcc variant (no
idea which one, though). While the shift/reduce conflict is fixable using
"%prec IFX" on the const:string rule, the colon breaks test?"a":"b".
Putting parentheses around "a" allows such a construct, requiring them
breaks comatibility with C. I think this feature just isn't worth that.
2013-06-26 23:04:35 +09:00
Bill Currie
257597fd38 Update ifstring in TODO
It seems to be done, but...
2013-06-26 23:04:35 +09:00
Bill Currie
cef2136050 Implement "not" logic for while and do-while.
This goes towards complementing the "if not" logic extension. I need to
check if fteqcc supports "not" with "while" (the version I have access to
at the moment does not), and also whether it would be good  to support
"not" with "for", and if so, what form the syntax should take.
2013-06-26 23:04:35 +09:00
Bill Currie
45a09e195e Add more TODO items (strings stuff) 2013-06-26 23:04:35 +09:00
Bill Currie
6fa63f6c54 Implement the basics of fteqcc's -Fifstring.
It's -Cifstring in qfcc, but otherwise the intent is the same. More testing
and investigation into what fteqcc does is required.
2013-06-26 23:02:55 +09:00
Bill Currie
8d34d33055 Implement "if not (foo)" syntax.
It is syntactic sugar for if (!(foo)), but is useful for avoiding
inconsistencies between such things as if (string) and if (!string), even
though qcc can't parse if not (string). It also makes for easier to read
code when the logic in the condition is complex.
2013-06-26 23:02:55 +09:00
Bill Currie
77337e2402 Separate "" and nil.
It turns out this is required for compatibility with qcc (and C, really).
Once string to boolean conversions are sorted out completely (not that
simple as qcc is inconsistent with if (string) vs if (!string)), Qgets can
be implemented :)
2013-06-26 23:02:55 +09:00
Bill Currie
fd1ea9e00e Add an option to control the enum switch warning. 2013-06-26 09:29:37 +09:00
Bill Currie
29df4ac7ee Fix case label lookup.
It looks like I had forgotten that the compare function is supposed to
return true/false (unlike memcmp's sorting ability). Also, avoid the
pointers in the value struct as they can change without notice.

Using enums in switches now works nicely, including warnings for unused
enum values.
2013-06-26 09:29:31 +09:00
Bill Currie
8ac2c3a04d Check for unused enum values in switch statements.
Unfortunately, it turns out the value lookup is broken (including for
duplicate cases).
2013-06-26 09:25:45 +09:00
Bill Currie
35bc981402 Allow use of a jump table when switching on an enum. 2013-06-26 09:25:45 +09:00
Bill Currie
64f76bd762 Use the right value when getting a function's defref.
Either I had gotten confused while writing the code and mixed up line and
offset, or I had changed offset to line at one stage but missed a place.
This fixes the segfault when compiling chewed-alias.r and return-ivar.r
2013-06-24 09:16:55 +09:00
Bill Currie
125ef1f0ff Move the whole separator test/creation into a function.
This will make the next stage easier. (except that seems to be slower)
2013-03-19 20:39:01 +09:00
Bill Currie
f2452eb3c3 Rewrite the inner-loop of FindSeparators.
For the most part, it's just refactoring the code so the plane creation and
testing are in separate functions, but there is one important difference:
the plane test now checks only the two points on either side of the point
used to create the plane.

Because the portal winding is guaranteed to be convex and planar, if both
points are on the plane, all points are, and if neither point is behind the
plane, no points are.a

This shaved about 5 seconds off the level 4 run using 4 threads (~198s to
~193s) and about 12s from the single threaded run (~682s to ~670s (hmm,
gained some time in recent changes)).
2013-03-19 17:00:00 +09:00
Bill Currie
d7c1bc8d02 Correct a comment.
I had gotten confused between figuring out the windings and writing the
comments, I guess.
2013-03-19 16:23:47 +09:00
Bill Currie
8938870e46 Make the default output a little nicer. 2013-03-19 13:07:44 +09:00
Bill Currie
dff0b89a6c Detect the number of CPUs available.
Now qfvis will default to multi-threaded on multi-core machines.
2013-03-19 12:05:50 +09:00
Bill Currie
88e5adcec6 Make the base vis multi-threaded.
Now multi-threaded qfvis is on par with tyrutils vis (differences usually
<1s, sometimes more, sometimes less).
2013-03-19 11:42:09 +09:00
Bill Currie
32b6d15931 Use a sorted queue for portals.
qsort is used to sort the queue by nummightsee. At ~4ms for 20k portals, I
think it's affordable. Using a queue rather than scanning the portal list
each time loses the dynamic sorting when mightsee gets updated, but it
seemed to shave off 4s anyway (~207s to ~203s (maybe, yay random times)).

Another step towards threaded base-vis.
2013-03-18 21:14:12 +09:00
Bill Currie
7e40981dcd Move the LeafThread setup to its own generic function.
This is for threading base-vis.
2013-03-18 21:11:46 +09:00
Bill Currie
cb096c601d Use a per-portal rwlock for portal updates.
This should make qfvis scale a little better with cpu count.
2013-03-18 15:03:11 +09:00
Bill Currie
c824e668ed Rework some of the pthread stuff.
Init/uninit is now separate from portal vising.
The global lock has a better name and is now a rwlock.
Use a separate lock for the stats.
2013-03-18 14:26:52 +09:00
Bill Currie
134381f79b Reduce the locking in the portal completion code.
It doesn't seem to make much difference, but the less room for contention,
the better.
2013-03-18 13:45:19 +09:00
Bill Currie
ffb6d628bd Simplify the pthreads detection macros. 2013-03-18 13:31:35 +09:00
Bill Currie
1c20a49dba Use the recursive set allocator for mightsee.
This completely removes the lock used to protect the set allocation code
while keeping the use of the set api clean.
2013-03-18 13:30:50 +09:00
Bill Currie
a28ec8aa82 Revert "Allocate stack blocks and mightsee in one block."
This reverts commit 1ea79e8626.

Conflicts:
	tools/qfvis/include/vis.h
	tools/qfvis/source/flow.c

I've decided to do reentrant versions of the set allocators and I didn't
particularly like the invasiveness of allocating sets this way.
2013-03-18 12:47:59 +09:00
Bill Currie
ad247fa12d Rename some variables and remove some comments.
The old variable names were confusing ("target" winding comes from
"portal"?), and the comments were from when I really didn't understand
concepts like separating planes. While they weren't wrong, they were quite
inadequate and I want to write new ones.
2013-03-17 21:52:08 +09:00
Bill Currie
ccc432a7ea Give the fields of pstack_t clearer names.
And some comments.
2013-03-17 19:18:38 +09:00
Bill Currie
1ea79e8626 Allocate stack blocks and mightsee in one block.
This bypasses set_new, but completely removes the use of the global lock
from within RecursiveClusterFlow. This seems to give a small speedup: 203
seconds threaded.
2013-03-17 16:37:27 +09:00
Bill Currie
1d262f7dea Clean up FindSeparators a little bit.
This was testing an idea I had to remove the plane flips. It seems to have
been good for the initial plane orientation, but was a slight slowdown for
the pass-portal test. However, this makes the code a little easier to work
with for my idea on improving the algorithm itself.
2013-03-17 10:16:47 +09:00
Bill Currie
5dba419233 Cache stack blocks and working mightsee sets.
Since the stack structure in the thread data is a linked list, move the
stack blocks off the program stack and into malloced memory. More
importantly, when the stack block is allocated, the mightsee working set is
allocated too, and as neither are freed, this greatly reduces contention
for the lock. Also, because the memory is kept, single threaded time for
gmsp3v2 dropped from 695s to 670s. Threaded is now about 207s (down from
350).
2013-03-16 22:58:59 +09:00
Bill Currie
2ea143283c Rewrite mightsee_more to manipulate the sets directly.
While using set operators was clearer, it was rather expensive (about 25s
for gmsp3v2). qfvis now completes the map in about 695s (single threaded).
About 15s faster than tyr for the same conditions (1 thread, level 4).
2013-03-16 21:51:41 +09:00
Bill Currie
195bdcb92f Rework FindSeparators to make use of the winding direction.
This is the second part of the separator search optimization from tyrutils
vis. With this, qfvis is getting close to tyrutils vis when
running single threaded (qfvis is suffering some nasty thread contention
and thus can't get below about 350 seconds with 4 threads). 808s vs 707s.
2013-03-15 22:05:01 +09:00
Bill Currie
9b10304c2f Make CopyWinding const-correct. 2013-03-15 19:25:24 +09:00
Bill Currie
5a2ee06787 Reverse the winding for backside portals.
This is part 1 of another optimization from tyrutils vis. It seems that
just reversing the winding gives a tiny speedup.
2013-03-15 19:22:57 +09:00
Bill Currie
46d41ad9ac Split up separator finding and winding clipping.
Interesting, it makes very little (maybe faster) difference to find all the
separators for levels 3 and 4. This might be due to the higher levels using
most of the planes to fully clip source away. Anyway, it makes the code a
little clearer (one function, one task).
2013-03-15 16:00:39 +09:00
Bill Currie
f80ae52828 Make vis's ClipWinding const-correct. 2013-03-15 15:28:25 +09:00
Bill Currie
77c858060d Add a bunch more statistics.
Now I know why sphere culling was a loss: 78% of all tested target portals
were trimmed by ClipToSeparators (50% eventually clipped away entirely).
2013-03-14 19:43:46 +09:00
Bill Currie
97da7fe31d Document some fields. 2013-03-14 19:43:46 +09:00
Bill Currie
8032d1d4d1 Split out the mightsee intersection/subset tests.
Having the code in separate functions makes the flow in the main loop a
little easier to follow.
2013-03-14 19:43:46 +09:00
Bill Currie
eec87bd61b Remove thread from stack_t.
It really wasn't gaining anything and made reading the code a little
harder.
2013-03-14 19:43:46 +09:00
Bill Currie
057a5cc624 Make BasePortalVis another 17% faster.
I had forgotten to skip the refined tests when the sphere was entirely on
the relevant side of the plane. Now BasePortalVis for gmsp3v2 takes 11s on
my machine (it was 13 with the previous optimization and 15.9 before that).

Also, write some comments describing how BasePortalVis works.
2013-03-14 14:01:26 +09:00
Bill Currie
5d6df082f2 Move the vis stats vars into thread data.
This should make the stats more reliable when running multi-threaded
(chains is still random, but it seems there are set access issues).
2013-03-14 12:52:40 +09:00
Bill Currie
0cae04d71a Alter test_sphere to return -1, 0 or 1.
Representing the side of the plane on which the sphere lies is much more
useful as more complicated tests can be done using just the one call.
-1: the sphere is entirely on the back side of the plane
 0: the sphere is intersecting the plane
 1: the sphere is entirely on the front side of the plane
2013-03-14 09:05:26 +09:00
Bill Currie
b9d71218f6 Use sphere culling in the base vis.
Base vis was done first for testing. Optimized base vis is down to ~12.4s
from ~16s (29% faster?).
2013-03-13 21:32:18 +09:00
Bill Currie
fe55bb678e Set the default level to 4.
It was supposed to be 2, but for some reason I neglected to set it when I
set up the options parsing. However, level 4 is the standard for production
maps, and it happens to be faster than level 2 (at least for gmsp3v2.bsp)
2013-03-09 15:01:54 +09:00
Bill Currie
3232c22795 Implement mightsee updates from tyrutils.
It doesn't seem to make much difference, but I suspect that's my set code
not being optimal for the job.
2013-03-09 14:32:51 +09:00
Bill Currie
d1e65257b6 Implement the cached separators idea from tyrutils.
I think the reason I didn't think of that when I tried to improve qfvis's
performance many years ago is I just simply did not understand
ClipToSeparators. However, the difference caching the separators makes is
phenomenal. Before the change, single threaded qfvis would get stuck on one
particular portal for at least a day (I gave up waiting), but now even a
debug build will complete gmsp3v2.bsp in less than 12 minutes (4 threads on
my quad-core). And that's at level 2! Getting stuck for a day was at level
0.
2013-03-08 22:20:29 +09:00
Bill Currie
ca0b03687f Change the naming of ALLOC's free-list.
Rather than prefixing free_ to the supplied name, suffix _freelist to the
supplied name. The biggest advantage of this is it allows the free-list to
be a structure member. It also cleans up the name-space a little.
2013-03-08 22:16:31 +09:00
Bill Currie
dbdfdb6d28 Add support for PRT2 portal files.
These seem to be identical to PRT1-AM but with a different count order in
the header. Taken from tyrutils-0.5.
2013-03-07 18:51:32 +09:00
Bill Currie
0649fd7022 Correct some verbosity levels. 2013-03-07 18:51:23 +09:00
Bill Currie
4e87072d93 Fix a bunch of whitespace. 2013-03-07 14:31:00 +09:00
Bill Currie
4ccb4a4667 Make the test and vis set pointers const. 2013-03-07 14:28:15 +09:00
Bill Currie
281c5f185d Correct the "can see anything new" check.
I had the super-set and sub-set parameters backwards, but that's because I
had misinterpreted the old code.
2013-03-07 14:24:30 +09:00
Bill Currie
81e4d3072c Plug a bunch of memory leaks.
Not that they really matter, but it makes reading valgrind's output a
little easier.
2013-03-07 13:42:19 +09:00
Bill Currie
9b4beaf3f8 Use a set for portalsee.
This removes the hard coding of the size of portalsee, which looks to have
been too small for some maps.
2013-03-07 11:35:08 +09:00
Bill Currie
299ff8f575 Use set functions for qfvis.
While noticeably slower than the previous expanded set manipulation code,
this is much easier to read. I can worry about optimizing the set code when
I get qfvis behaving better.
2013-03-07 11:06:55 +09:00
Bill Currie
5950803462 Implement the sun lighting calculations.
The sun(s) won't work right now because the vectors aren't properly set up.
2013-03-07 09:11:23 +09:00
Bill Currie
4d4bcaf3a3 Make the Test functions const-correct. 2013-03-07 09:11:23 +09:00
Bill Currie
0e82b37001 Parse the sun information from the worldspawn entity. 2013-03-07 09:11:23 +09:00
Bill Currie
f1a18742f1 Cache the worldspawn entity.
It is an error (for now) if there is not exactly one worldspawn entity.
2013-03-07 09:11:23 +09:00
Bill Currie
4f0a1df3c1 Implement sky tracing.
Again, this is from Jardrup's light tool. Sun data is not yet parsed, nor
are any sun lighting calculations done.
2013-03-07 09:11:23 +09:00
Bill Currie
7cd1894a6d Add the solid-sky option from Jardrup's light tool.
However, actual sky tracing is not yet implemented.
2013-03-07 09:11:23 +09:00
Bill Currie
32127d3ec7 Kill a sprintf.
While 16 chars is enough for any 32-bit int, if int ever changes to 64
bit... (need 21). Just avoid the issue with good old va :)
2013-03-07 09:11:23 +09:00
Bill Currie
d2909cd4dd Clear the padding in the light data buffers.
Getting uninitialized memory in calloced space was interesting :P
2013-03-07 09:11:23 +09:00