Commit graph

913 commits

Author SHA1 Message Date
alexey.lysiuk
34f2d8f310
- fixed typo in error message 2018-08-18 17:45:26 +03:00
alexey.lysiuk
31bd7cfc04
- prohibit assignment of dynamic arrays
https://forum.zdoom.org/viewtopic.php?t=61682
2018-08-18 15:20:38 +03:00
Magnus Norddahl
9d68d43ce7 - disable all unimplemented opcodes in the switch to ensure 'Unknown VM opcode' fatal error is generated if CanJit has a bug 2018-08-18 13:18:52 +02:00
Magnus Norddahl
68b2cd58d8 Fix compile errors on macOS 2018-08-18 12:37:33 +02:00
alexey.lysiuk
d965c9aa76
- support static const arrays inside structs
https://forum.zdoom.org/viewtopic.php?t=61677
2018-08-18 13:00:33 +03:00
Jonathan Russell
6a40e092fe - added remaining int arithmetic opcodes (and fixed float loading offset issue) 2018-08-17 22:06:12 +01:00
Jonathan Russell
758ee5cbfb - forgot to turn off debug switch in last commit 2018-08-17 19:15:27 +01:00
Jonathan Russell
08c0ac541f - made absMaskInt const 2018-08-17 19:14:31 +01:00
Jonathan Russell
d137b3c94e - implemented CMP_APPROX for OP_EQF_*, making ~== work for doubles 2018-08-17 19:08:19 +01:00
Marisa Kirisame
155afebb65 Add HITOWNER flag, when set, allows a projectile to collide with its shooter. 2018-08-17 19:47:12 +02:00
Chronos Ouroboros
079391e5ac Updated CanJit's supported opcodes list. 2018-08-16 21:45:04 +02:00
Chronos Ouroboros
a8ce626708 Pointer addition opcodes must leave NULL pointers as they are. 2018-08-16 21:45:04 +02:00
Chronos Ouroboros
591783087d Changed binary int ops to use a temporary register, fixed some opcodes.
For some reason, binary ops might reuse one of the input registers as the output register.
This is a problem for very obvious reasons.
2018-08-14 20:08:04 -03:00
Jonathan Russell
dc03cb7a80 - made CMP_CHECK checking compile time 2018-08-14 20:50:32 +01:00
Jonathan Russell
740415246e - added exact floating point comparison opcodes 2018-08-14 18:32:17 +01:00
Jonathan Russell
167693f102 - implemented all integer comparison operators 2018-08-14 15:07:09 +01:00
Jonathan Russell
b30df47499 - adds OP_EQ_R, the first instruction using jumps 2018-08-14 13:02:56 +01:00
Magnus Norddahl
0ced612d2c - add misc float opcodes 2018-08-14 01:07:30 +02:00
Jonathan Russell
cdb5a9d91e - added most vector maths opcodes 2018-08-13 21:36:55 +01:00
Chronos Ouroboros
cb28bbc72e Fix floats and implement some more opcodes. 2018-08-13 13:07:36 -03:00
Magnus Norddahl
83d769f55c - copy initial register values from the VM frame 2018-08-13 00:15:42 +02:00
Magnus Norddahl
7108fd6228 - implement most of the integer math opcodes 2018-08-12 04:34:57 +02:00
Magnus Norddahl
cbb945d8a7 - embed and use asmjit to JIT ZScript VM functions 2018-08-12 02:11:13 +02:00
Christoph Oelckers
6634416b89 - allow skipping optional arguments of the parent function in a virtual override definition.
This is mainly to allow retroactive addition to existing virtual functions without breaking existing content.
The MeansOfDeath fix for Actor.Die would not be possible without such handling.
2018-07-29 17:00:05 +02:00
alexey.lysiuk
e9041c0697 - fixed potential garbage collection of still referenced objects
Objects from dynamic array stored in items of array of structures were incorrectly treated as unreachable

https://forum.zdoom.org/viewtopic.php?t=61354
2018-07-28 19:34:20 +02:00
Christoph Oelckers
6d0b172762 - added MF8_DONTFACETALKER flag which prevents NPCs from facing the player in conversations. 2018-07-22 11:32:45 +02:00
Christoph Oelckers
2a0c3e63a3 - allow temporary strings to be used as self pointer for String's member functions.
Due to how function calls get resolved by the code generator there were some incorrect flags on the self pointer which triggered an assert and caused incorrect code generation.
Fortunately this was a mostly contained special case for which a workaround was possible.
2018-07-20 10:38:55 +02:00
alexey.lysiuk
b2697a99f8 - added missing null pointer checks to VM ops 2018-07-16 17:10:47 +03:00
alexey.lysiuk
5d27c16f30 - disabled default values for out parameters
https://forum.zdoom.org/viewtopic.php?t=61128
2018-06-30 11:44:22 +03:00
Christoph Oelckers
ae1fe041ee - ZScript used the wrong variable for compatflags2.
ii_* is merely the storage for info from the compatibility.txt lump.
2018-06-09 17:59:21 +02:00
alexey.lysiuk
4a1f36623b - fixed: flag CVars in ZScript referenced wrong addresses 2018-06-09 17:21:55 +03:00
Christoph Oelckers
1fdcacc337 - redirect script access to the compatflags CVARs to their internal shadow variables.
This is needed so that MAPINFO settings for these flags don't get ignored.
2018-06-08 22:55:44 +02:00
Marisa Kirisame
fae514f30d BLOCKASPLAYER flag: treat non-player actors as blockable by "block players" lines 2018-06-04 22:18:51 +02:00
Christoph Oelckers
7d515e72c2 - fixed: FxFloatCast must transfer the outer expression's value type to the inner expression if it performs a float->float cast.
This violated an important rule that a cast may not alter the expression's type and led to failed asserts elsewhere.
2018-06-02 07:50:23 +02:00
alexey.lysiuk
ef536e7b00 - fixed crash in DECORATE parsing
The case with forward declared class used as a parent must be handled explicitly

actor MyWeapon : Weapon { Weapon.AmmoType "MyBaseAmmo" }
actor MyAmmo : MyBaseAmmo { }
actor MyBaseAmmo : Ammo { }
2018-05-10 11:47:16 +03:00
alexey.lysiuk
2ae8d39441 Removed all superfluous #include's
Automatically optimized by CLion IDE with manual corrections
2018-04-24 14:30:35 +03:00
Christoph Oelckers
cf8447d19c -protected critical portal data from getting written to by user code.
This data is game critical and may only be altered by code that knows what is allowed and what not. It must never be altered by any user code ever.
However, since the SkyViewpoint actors need to set up some relations between themselves and the default sky portals the previously purely internal 'internal' flag has been exported as a new keyword.
2018-04-15 12:13:02 +02:00
alexey.lysiuk
7bd281ddc9 Added zero initialization of implicit dynamic array items
https://forum.zdoom.org/viewtopic.php?t=60111
2018-04-05 12:22:41 +03:00
alexey.lysiuk
ac7e5def32 Forbade dynamic array as the return type of a function
Compiler ignored this case silently but it crashed during code generation
2018-04-02 15:18:30 +03:00
alexey.lysiuk
ff96980dda Fixed handling of default values in String.Mid()
https://forum.zdoom.org/viewtopic.php?t=60047
2018-03-31 21:45:20 +03:00
Christoph Oelckers
e89a598b31 - renamed FTexture's UseType flags and gave them a dedicated type.
This was done mainly to reduce the amount of occurences of the word FTexture but it immediately helped detect two small and mostly harmless bugs that were found due to the stricter type checks.
2018-03-25 20:26:16 +02:00
Jason Francis
bd7791ad9c Allow setting string user variables in ACS 2018-03-24 10:20:39 +01:00
Jason Francis
4494b18e8a Enable string & float user_ properties in UDMF things 2018-03-24 10:20:39 +01:00
Christoph Oelckers
f1bfc3514d - fixed: For proper recognition of optional function arguments, the argflags must also be copied from the parent function to ensure they are itdentical on the override. 2018-03-14 19:52:30 +01:00
Christoph Oelckers
5d436cd3ed - forward the error state of the translation parser to the calling code so that it can print a message pointing to the problem content. 2018-03-12 19:14:56 +01:00
Christoph Oelckers
13ef97c4ac - removed debug message. 2018-03-12 18:47:49 +01:00
Major Cooke
4851c5bfde Insert an extra line after printing the warnings. 2018-03-12 18:17:08 +01:00
Christoph Oelckers
def5e1d61b Added proper handling for default parameter values of virtual overrides
Due to how the VM handles default parameters, these must always be identical to the parent to prevent undefined behavior.
So now, if such parameters are encountered, the compiler will either abort (for script version >= 3.3) or print a warning (for older versions.)
Any defaults being specified for older versions will be ignored, though, and the defaults of the parent function be copied to the override.
2018-03-12 10:19:16 +01:00
alexey.lysiuk
81bc05b7c5 Added support for default values of arguments with uint type 2018-03-07 15:58:06 +02:00
Christoph Oelckers
bcc8972356 - fixed: A preincrement of a local variable generated wrong code if passed as a function parameter.
Due to the special nature of this expression the code generator got stuck in 'address' mode and passed the address of the variable instead of its value.
2018-03-01 15:00:18 +01:00
Christoph Oelckers
425f1408f7 - fixed skip_super application fro ZScript.
The order of processing is different here so when the property gets parsed there are no states to delete.
To fix this the property just flags the class and lets the ZScript state compiler deal with this as needed.
2018-02-28 18:10:04 +01:00
Christoph Oelckers
af14609de7 - don't skip empty arrays which are themselves array elements in the ZScript serializer. 2018-02-27 15:42:22 +01:00
Christoph Oelckers
aaaf9aa108 Added 'TeleportSpecial' as an alias for 'Teleport' in ZScript to deconflict from the Actor.Teleport function. 2018-02-27 12:44:00 +01:00
alexey.lysiuk
74357ced0c Fixed read of potentially junk values in ZScript parser
The following ill-formed ZScript code might crash targets with sizeof(int) != sizeof(void*) like 64-bit Intel
class test { void func() { if (true) ( return; ) } }
2018-02-21 16:26:04 +02:00
alexey.lysiuk
1e41c042d4 Fixed codegen crash with non-numeric random seed
The following code crashed ZScript code generator if my_seed is not convertible to numeric type
SetRandomSeed[my_random_id](my_seed);
2018-02-19 11:46:36 +02:00
Christoph Oelckers
09f1859c83 - allow retrieving the length of a string constant. 2018-01-21 18:49:46 +01:00
Christoph Oelckers
dbf0a68b02 Merge commit '67e3106254e987f5acb9534e725d4f5c3eaa82b2'
# Conflicts:
#	src/doomdata.h
#	src/namedef.h
#	src/p_udmf.cpp
2018-01-20 19:07:54 +01:00
Christoph Oelckers
19cf887ad1 - fixed: Dynamic arrays for object pointers need different treatment than arrays for regular pointers, because they require GC::WriteBarrier to be called. 2018-01-19 19:49:42 +01:00
alexey.lysiuk
6d20da8ab5 Fixed nust -> must typos 2018-01-18 11:43:32 +02:00
Magnus Norddahl
5f36b86013 - Add dynamic spot lights 2018-01-04 17:58:11 +01:00
alexey.lysiuk
d50ba4954a Fixed potential crash when calling undefined function in ZScript
The following code which uses explicit class specifier led to a crash:
class C
{
	void F()
	{
		Object.Undefined();
	}
}
2017-12-23 15:27:32 +02:00
Christoph Oelckers
ab58e4acb0 - use FileWriter for the AST dump. 2017-12-02 12:01:55 +01:00
alexey.lysiuk
5d83ee5e89 Exposed String.Remove() function to ZScript
https://forum.zdoom.org/viewtopic.php?t=58402
2017-11-12 14:44:21 +02:00
alexey.lysiuk
4beefb7007 Removed warning for uninitialized variables in ZScript
This reverts commit 8104ef5189
2017-11-06 15:38:28 +02:00
alexey.lysiuk
274951839a Removed unused parameter from several functions in FStateDefinitions class
src/p_states.cpp:724:54: warning: parameter ‘actor’ set but not used [-Wunused-but-set-parameter]
https://forum.zdoom.org/viewtopic.php?t=58364
2017-11-05 15:20:25 +02:00
alexey.lysiuk
8104ef5189 Added warning for uninitialized variables in ZScript
https://forum.zdoom.org/viewtopic.php?t=57868
2017-11-03 16:23:41 +02:00
alexey.lysiuk
dac5777a70 Removed obsolete declarations from codegen.h 2017-11-03 12:44:28 +02:00
alexey.lysiuk
81ea9fb372 Added runtime check for negative array indices in VM
https://forum.zdoom.org/viewtopic.php?t=57886
2017-11-02 18:01:13 +02:00
alexey.lysiuk
57de598e48 Added implicit scope for if/else, while and do/while statements in ZScript
Scope is added only for variable or constant definition so it will no longer leak to outer scope
https://forum.zdoom.org/viewtopic.php?t=57848
2017-11-02 17:10:54 +02:00
alexey.lysiuk
de7d8995d5 Added string representation of 'static const' token
No more 'Unknown(-141)' in 'Expecting ...' error message
2017-11-02 14:45:35 +02:00
alexey.lysiuk
62e91b23bd Extended String.LastIndexOf() with endIndex parameter
https://forum.zdoom.org/viewtopic.php?t=57326
2017-11-01 15:24:05 +02:00
alexey.lysiuk
c4865d2bb6 Exposed string split functionality to ZScript
https://forum.zdoom.org/viewtopic.php?t=58114
2017-10-28 11:44:12 +03:00
alexey.lysiuk
40a348b1f1 Fixed potential crash in resolving of multiple assignment
https://forum.zdoom.org/viewtopic.php?t=58055
https://forum.zdoom.org/viewtopic.php?t=58237
2017-10-27 18:15:24 +03:00
alexey.lysiuk
cb982ec313 Use FString::Back() when possible
Changed usages of str[str.Len() - 1] to str.Back()
2017-10-23 11:55:20 +03:00
alexey.lysiuk
48f9e53580 Added better error message for invalid class/struct member
https://forum.zdoom.org/viewtopic.php?t=57959
2017-09-24 10:25:05 +03:00
Magnus Norddahl
cfc1bfd1e2 - Fixed FxPow::Resolve not specifying the ValueType 2017-09-24 01:15:58 +02:00
Christoph Oelckers
eade38fb09 - fixed crash when defining a global constant which references a class member constant in its value. 2017-09-02 08:14:50 +02:00
Christoph Oelckers
948e50e458 - fixed: The struct field compiler did not check for forward declared type references that hadn't been resolved yet. 2017-08-27 12:31:47 +02:00
alexey.lysiuk
7b98fdb910 Added ToInt() and ToDouble() functions to ZScript string
https://forum.zdoom.org/viewtopic.php?t=57678
2017-08-25 15:09:18 +03:00
Christoph Oelckers
b4fa95ab15 - handle state label resolution in a non-actor cpntext more gracefully.
Note that this is merely a hotfix. Properly handling this to allow universal use of state scopes will require more work in cases where a scoped state is being accessed through a non-self pointer.
2017-08-12 10:04:06 +02:00
alexey.lysiuk
33beca6e6f Exposed ToLower() and ToUpper() string functions to ZScript
https://forum.zdoom.org/viewtopic.php?t=57515
2017-08-07 15:24:18 +03:00
Rachael Alexanderson
91ff447a90 - fixed compile from last commit
- refactored the zscript hookup a bit, made it actually work
2017-07-29 17:03:43 -04:00
Rachael Alexanderson
712d21e26a - implement per-renderer sprite hiding based on the actor's render feature flags
- hook the thing up to zscript (does not currently compile)
2017-07-29 17:03:43 -04:00
alexey.lysiuk
7436693860 Enabled dynamic stack size in ZScript parser generated by Lemon
https://forum.zdoom.org/viewtopic.php?t=57322
2017-07-23 11:54:16 +03:00
alexey.lysiuk
c56cd245ac Added IndexOf() and LastIndexOf() functions to ZScript string type
https://forum.zdoom.org/viewtopic.php?t=57313
2017-07-22 10:54:32 +03:00
Christoph Oelckers
daca12600d - fixed: The ADDA_RK opcode used the wrong constant type for the offset it adds to the pointer. 2017-07-15 09:14:39 +02:00
alexey.lysiuk
71b70d74a9 Fixed error handling in vector by scalar multiplication
https://forum.zdoom.org/viewtopic.php?t=57089
2017-07-01 12:37:31 +03:00
alexey.lysiuk
279b1e27dc Made usage of assertions in VM code consistent
https://forum.zdoom.org/viewtopic.php?t=56995
2017-06-22 10:36:08 +03:00
Christoph Oelckers
3b024c347b - use a dedicated flag word for the dynamic light flags instead of piggybacking on some flags4 bits. 2017-06-18 10:15:31 +02:00
alexey.lysiuk
eda55b25ee Fixed code generation for vector parameters with default values
https://forum.zdoom.org/viewtopic.php?t=56915
2017-06-16 11:58:24 +03:00
Christoph Oelckers
1ed415014e - fixed: 'self' may never be null for native VM functions so it must always abort if null gets passed. 2017-06-05 08:43:12 +02:00
Christoph Oelckers
91680a1e8d - fixed incorrect number of returns in SetRandomSeed. 2017-06-04 18:56:03 +02:00
Rachael Alexanderson
2997f31f9f - removed ZDOOMADD and updated actors in question with ZDOOMTRANS 2017-06-04 12:30:35 +02:00
Rachael Alexanderson
89b372cb01 - Changed MF7_SPRITEFLIP, MF8_ZDOOMTRANS to RenderFlags
- Added RF_ZDOOMADD
- renamed r_canontrans to r_vanillatrans
- this developer's insanity level has increased by 231%.
2017-06-04 12:30:35 +02:00
Rachael Alexanderson
01f88cfb16 - Added 'canonical transparency' cvar r_canontrans - this simply turns off transparency for Doom objects that were marked as transparent sometime in ZDoom's development cycle 2017-06-04 12:30:35 +02:00
jplebreton
2c7a0c87c8 add FloatBobStrength Actor property, a multiplier on Z offset created by FloatBob behavior. default of 1.0 is current behavior, set higher/lower for more/less extreme bobbing. 2017-06-03 18:02:27 +02:00
Christoph Oelckers
1465102ba0 - added SetRandomSeed function for ZScript. This uses the same RNG syntax as the other random functions. 2017-05-31 11:33:57 +02:00
Christoph Oelckers
b50123ec6b - avoid function call in VM code.
- return after calling ThrowAbortException because this avoids storing some register variables on the stack.
2017-05-30 17:50:56 +02:00
alexey.lysiuk
62bac1d612 Added check for nullptr to CLSS and META instructions of scripting VM
https://forum.zdoom.org/viewtopic.php?t=56667
2017-05-30 18:09:51 +03:00
Christoph Oelckers
97b664968e - removed a few unused VM opcodes. 2017-05-19 10:27:22 +02:00
Rachael Alexanderson
a96ef5276d - Added new flags8 actor field. Isn't it frightening how quickly how we got to our 8th flag field?
- Speaking of frightening, added +FRIGHTENING flag.
2017-05-15 19:17:46 +02:00
Rachael Alexanderson
2acb485121 - Added +SPRITEFLIP which reverses a sprite's left-rightness. 2017-05-03 21:13:31 +02:00
Christoph Oelckers
aac6e65842 - fixed: FxActionSpecialCall did not resolve float to int casts. 2017-05-01 22:44:58 +02:00
alexey.lysiuk
ea3b47d0ad Added generic workaround for double type alignment
This fixes not only 32-bit Linux/macOS builds but PowerPC Mac target too
2017-04-23 14:49:36 +03:00
Christoph Oelckers
57d703236b - changed Doom source license to GPL in all subdirectories and fixed missing licenses in a few other files. 2017-04-17 12:27:19 +02:00
Christoph Oelckers
2d0da4fcfa - fixed: Dynamic arrays of objects in structs were not registered for garbage collection. 2017-04-15 13:20:58 +02:00
Christoph Oelckers
e333e31410 - fixed: Vector array elements failed to allocate the proper amount of registers. 2017-04-15 12:03:21 +02:00
Christoph Oelckers
ca1981c52f - fixed missing null pointer check in BuiltinNameToClass. 2017-04-14 23:06:12 +02:00
Christoph Oelckers
d014395dae - do not delete the namespaces when removing compiler symbols. They still get referenced by some types and must remain until the engine shuts down. 2017-04-14 19:40:50 +02:00
Christoph Oelckers
7186342221 - do not try to serialize static arrays. 2017-04-14 19:25:47 +02:00
Christoph Oelckers
92acbdc625 - made GetClassName an intrinsic and expanded it to also work on class types. 2017-04-14 16:14:27 +02:00
Christoph Oelckers
7983f6ea4f - fixed incorrect return variable. 2017-04-14 15:23:18 +02:00
Christoph Oelckers
cd180d29c7 - block direct use of 'new' for DObjects.
This is to ensure that the Class pointer can be set right on creation. ZDoom had always depended on handling this lazily which poses some problems for the VM.
So now there is a variadic Create<classtype> function taking care of that, but to ensure that it gets used, direct access to the new operator has been blocked.

This also neccessitated making DArgs a regular object because they get created before the type system is up. Since the few uses of DArgs are easily controllable this wasn't a big issue.

- did a bit of optimization on the bots' decision making whether to pick up a health item or not.
2017-04-14 13:31:58 +02:00
Christoph Oelckers
2d098e99fb - fixed: WP_NOCHANGE had different values in native and script code, resulting in problems with weapon selection.
This now explicitly allocates a single object it can safely point to instead of trying to hack around it.
2017-04-13 18:59:45 +02:00
Christoph Oelckers
98dab9c4b9 - took PTypeBase and all its subclasses out of the DObject hierarchy.
- moved scope flag to a new variable that is specific to PType instead of hijacking the ObjectFlags for this.
2017-04-13 17:47:17 +02:00
Christoph Oelckers
988fe8d735 - removed all RTTI from the type table.
Using names is just as good as using types so now this is what's done.
2017-04-13 16:01:38 +02:00
Christoph Oelckers
aeb455d705 - removed all RTTI checks for the types. 2017-04-13 15:38:06 +02:00
Christoph Oelckers
b2d944974e - first stage of simplifying the type system.
Let's use inline checkers in PType instead of constantly having to do clumsy IsKindOf checks etc. Once complete this also means that the types can be taken out of the class hierarchy, freeing up some common names.
2017-04-13 12:52:18 +02:00
alexey.lysiuk
fbc1028d2b Fixed crash when parsing DECORATE constant expressions 2017-04-13 12:06:59 +03:00
alexey.lysiuk
1889efa814 Fixed build with Clang
Fixed bunch of compilation errors:
cannot pass non-trivial object of type 'FString' to variadic method; expected type from format string was 'char *' [-Wnon-pod-varargs]

Fixed linker erorr:
g_doomedmap.cpp.o: In function `InitActorNumsFromMapinfo()':
src/g_doomedmap.cpp: undefined reference to `PClass::FindActor(FName)'
2017-04-13 10:40:43 +03:00
Christoph Oelckers
1712667ce2 Merge branch 'master' of https://github.com/coelckers/gzdoom 2017-04-13 02:18:16 +02:00
Christoph Oelckers
85d8244d03 - fixed: With the reorganization of the class data the setup of actor replacements must be delayed until after InitializeDefaults has been called. 2017-04-13 02:18:06 +02:00
Christoph Oelckers
6599e2c425 - moved the VM types into their own file and only include it where really needed. 2017-04-13 01:12:04 +02:00
Christoph Oelckers
fc9e304189 - separated class descriptors from VM types.
Combining these two groups of data has been the cause of many hard to detect errors because it allowed liberal casting between types that are used for completely different things.
2017-04-12 22:46:49 +02:00
Christoph Oelckers
afd6743965 - moved AddNativeField to PSymbolTable, too. 2017-04-12 18:29:58 +02:00
Christoph Oelckers
8dc11317dd - Moved WriteFields into SymbolTable as well. 2017-04-12 17:42:10 +02:00
Christoph Oelckers
96631e8808 - make PClass not inherit from PStruct.
Having these two types related can cause problems with detection in the compiler because for some parts they need quite different handling.
Common handling for the fields has been moved into PSymbolTable but overall redundancy was quite minor as both types share surprisingly little functionality.
2017-04-12 17:21:13 +02:00
alexey.lysiuk
20a9f17a15 Fixed handling of count parameter's default value in Array.Delete()
https://mantis.zdoom.org/view.php?id=571
2017-04-12 17:40:17 +03:00
Christoph Oelckers
0d7b7d6ab1 - merged PStruct and PNativeStruct.
There were exactly 4 places in the code that checked for the difference, this is better done with a flag.
2017-04-12 15:12:41 +02:00
Christoph Oelckers
6308251084 - added a FindSymbol wrapper to PClass so that other code does not need to access the symbol table directly.
- added an isActor utility function to codegen.cpp to simplify a few constructs.
2017-04-12 13:08:41 +02:00
Christoph Oelckers
b17ab7a133 - put PObjectPointer to some use.
- fixed: There was no check for compatible class pointers.
2017-04-12 11:40:40 +02:00
Christoph Oelckers
80801d11b1 - removed some redundant static_casts. 2017-04-12 10:29:04 +02:00
Christoph Oelckers
9c9b2ccf6d - replaced more dyn_casts and checks for RUNTIME_CLASS(PClassActor)
It is preferable to use IsDescendantOf wherever possible if we ever want to be able to separate PClass from PType.
2017-04-12 10:20:58 +02:00
Christoph Oelckers
5350721ec5 - removed PClass::DeriveData because it is no longer needed.
- fixed: IsVisibleToPlayer and optimized it a bit more.
- moved SourceLumpName to PClass, so that it can also be used for non-actors (there's a lot of non-Actor classes already.)
- separated the serializer for PClassPointer from PPointer. Even though not doable, a pointer to a class type is something entirely different than a class pointer with a restriction so each should handle its own case.
2017-04-12 09:55:27 +02:00
Christoph Oelckers
e4d2380775 - moved all remaining fields from PClassActor to FActorInfo.
- added a few access functions for FActorInfo variables.

With PClassActor now empty the class descriptors can finally be converted back to static data outside the class hierarchy, like they were before the scripting merge, and untangle the game data from VM internals.
2017-04-12 00:07:41 +02:00
Christoph Oelckers
854053a14f - use TArrays instead of TMaps to store damage factors and pain chances.
For these fields maps have no advantage. Linearly searching a small array with up to 10 entries is nearly always faster than generating a hash for finding the entry in the map.
2017-04-11 23:29:37 +02:00
Christoph Oelckers
4afe2d4218 - moved OwnedStates and NumOwnedStates out of PClassActor. 2017-04-11 22:44:35 +02:00
Christoph Oelckers
05240ccbe5 - fixed redundant reallocation of constructable meta fields.
- some optimization of access to OwnedStates in old DECORATE.
- consolidate all places that print a state name into a subfunction.
- allocate states from the ClassDataAllocator memory arena. States do not need to be freed separately from the rest of the static class data.
2017-04-11 21:48:41 +02:00
Christoph Oelckers
311ce2362a - started moving stuff out of PClassActor into meta data.
This reinstates the old FActorInfo as part of the meta data a class can have so that the class descriptor itself can be freed from any data not directly relevant for managing the class's type information.
2017-04-11 19:37:56 +02:00
Christoph Oelckers
6a3ddaa8fa - moved Restricted/ForbiddenToPlayerClass fully to the script side.
This required some fixes for allowing to read from metadata arrays.
2017-04-11 15:11:13 +02:00
Christoph Oelckers
7a6e70e777 - reenabled the part of OP_THROW that throws a VMAbortException. This part is still needed for a runtime variable access check. 2017-04-11 00:11:36 +02:00
alexey.lysiuk
d5edd3db36 Commented out remains of VM exception handling opcodes
This fixes build with GCC/Clang
2017-04-10 22:18:43 +03:00
Christoph Oelckers
040c70714c - commented out the exception handling opcodes in the VM.
They are currently not used and not planned to be used - and they are rather costly by increasing stack size per call quite significantly.
2017-04-10 20:41:55 +02:00
Christoph Oelckers
9ae97502be - removed the last remnants of the ATAGs. 2017-04-10 17:08:52 +02:00
Christoph Oelckers
60dd58e7d2 - most ATAG stuff is gone, except for the static storage space in the VMFunction. 2017-04-10 16:06:18 +02:00
Christoph Oelckers
5464336035 - removed ATAGs from the function builder. 2017-04-10 15:48:27 +02:00
Christoph Oelckers
e551ef52f8 - removed atag parameter from GetConstantAddress. 2017-04-10 15:39:04 +02:00
Christoph Oelckers
ef77cbd295 - stop using the ATAGs for checking pointer types in asserts.
This is an incredibly costly way to do a debug check as it infests the entire VM design from top to bottom. These tags are basically useless for anything else but validating object pointers being passed to native functions (i.e. mismatches between definition and declaration) and that simply does not justify a feature that costs execution time in non-debug builds and added memory overhead everywhere.
Note that this commit does not remove the tags, it only discontinues their use.
2017-04-10 15:18:31 +02:00
Christoph Oelckers
74faacd218 - fixed: FxVMFunctionCall::GetDirectFunction did not perform any checks on the function's self pointer and failed to report a mismatch as an error.
- also fixed two places in the code where the above caused some incorrect definitions not to be detected.
2017-04-06 20:52:38 +02:00
Christoph Oelckers
e780cd8297 - seems the wrong version of this got committed... 2017-04-01 12:04:31 +02:00
Christoph Oelckers
41f2f61b94 - minor VM optimization: Precalculate a function's frame size when compiling it instead of doing it each time it gets called.
This made up ca. 10% of the 'call' instruction's execution time.
2017-04-01 10:42:47 +02:00
Christoph Oelckers
3f9ad55432 - allow multiple expressions in 'for' iteration part. 2017-03-29 22:18:52 +02:00
Christoph Oelckers
19e7d60275 - removed DSBarInfo::Scaled because it tended to disagree with StatusBar->Scaled. 2017-03-29 00:35:35 +02:00
Christoph Oelckers
2d1641f0cd - fixed: Reference types passed as a reference parameter were not properly checked for. 2017-03-29 00:00:25 +02:00
nashmuhandes
99d1581c27 Added "DontLightActors" flag for dynamic lights. Actors will not be illuminated by lights that are given this flag. 2017-03-28 21:33:16 +02:00
Christoph Oelckers
a6bf93c624 - implemented the Heretic status bar. 2017-03-27 21:01:40 +02:00
Christoph Oelckers
a3ee3c287e - major progress on the status bar code: SBARINFO's DrawGraphic has been ported into a generic function of the base statusbar class and put to use for a few items on the Strife status bar.
- decided to ditch the widget system I had started to lay out. As it turns out that would make things far more complicated and slower than they need to be.
2017-03-24 00:47:08 +01:00
Christoph Oelckers
31ea33bfc4 - rewrote the condition nodes from SBARINFO in ZScript. This compiles but hasn't been tested yet. 2017-03-23 00:25:26 +01:00
Christoph Oelckers
9bd75bcac5 - some conceptual work on statusbar stuff. This looks like a viable approach to build something that can replace SBARINFO. 2017-03-22 19:56:21 +01:00
Christoph Oelckers
4417afd548 - changed VMValue to handle strings by reference.
This makes VMValue a real POD type with no hacky overloads and eliminates a lot of destructor code in all places that call a VM function. Due to the way this had to be handled, none of these destructors could be skipped because any value could have been a string.
This required some minor changes in functions that passed a temporary FString into the VM to ensure that the temporary object lives long enough to be handled. The code generator had already been changed to deal with this in a previous commit.
This is easily offset by the code savings and reduced maintenance needs elsewhere.
2017-03-22 01:44:56 +01:00
Christoph Oelckers
9bffe4ee50 - scriptified the main statusbar interface and the Strife status bar.
Note that the Strife status bar does not draw the health bars yet. I tried to replace the hacky custom texture with a single fill operation but had to find out that all the coordinate mangling for the status bar is being done deep in the video code. This needs to be fixed before this can be made to work.

Currently this is not usable in mods because they cannot initialize custom status bars yet.
2017-03-22 00:32:52 +01:00
alexey.lysiuk
7aa6a6b0b3 Restored explicit assignment operators for VMValue
Unfortunately strings require special handling and so all operators must be available
This partly solves https://mantis.zdoom.org/view.php?id=453 (and https://mantis.zdoom.org/view.php?id=459 too)
2017-03-21 12:14:50 +02:00
Christoph Oelckers
1031481167 - added some checks to exclude dynamic lights from being subjected to shadowmapping if they do not touch any one-sided lines from the back side. This condition is a requirement for a 1D shadowmap to even have an effect. 2017-03-20 00:34:19 +01:00
Christoph Oelckers
0721aef218 - fixed: FxAssign used the wrong value type for emitting the store operation.
It used the expression's value type, but needs to use the variable's, which can be different when the assignment is synthesized from a builtin function.
2017-03-19 21:36:18 +01:00
Christoph Oelckers
403c5693a9 - cleaned out a large part of unused methods from VMValue.
- keep string registers which are being used as function parameters allocated until after the function call returns. This is for allowing to pass strings by reference which would avoid some costly constructor/destructor loops in the call instruction.
2017-03-19 21:25:30 +01:00
Christoph Oelckers
ac95cba848 - fixed generic class type properties to handle "" and "none" as 'no class'. 2017-03-19 12:02:17 +01:00
Christoph Oelckers
845c43876c - moved all trivial actor properties into the scripts as 'property' declarations. 2017-03-19 11:30:28 +01:00
Christoph Oelckers
3cced6c7cc - fixed the early-outs for empty functions in the VM caller.
OP_RET should not be used as an absolute number here.
2017-03-18 21:31:43 +01:00
Christoph Oelckers
a2f2be17ef - status screen fully scriptified but not active yet. 2017-03-18 19:35:26 +01:00
Christoph Oelckers
74e9d9db1a - fixed: The evaluation of multi-string ZScript properties did not work correctly. 2017-03-18 15:45:36 +01:00
alexey.lysiuk
cb5ddeff25 Fixed compilation warnings reported by Clang
src/gl/scene/gl_clipper.h:150:23: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
src/gl/dynlights/gl_aabbtree.cpp:137:24: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:137:34: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:137:44: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:139:6: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:139:30: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:139:54: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:142:6: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:143:3: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:144:3: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_aabbtree.cpp:167:6: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
src/gl/dynlights/gl_shadowmap.cpp:163:31: warning: '&&' within '||' [-Wlogical-op-parentheses]
src/p_saveg.cpp:367:16: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
src/p_saveg.cpp:402:60: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
src/p_setup.cpp:1553:39: warning: format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'int' [-Wformat]
src/scripting/zscript/zcc_compile.cpp:293:74: warning: field 'AST' will be initialized after field 'mVersion' [-Wreorder]
src/swrenderer/drawers/r_thread.cpp:113:21: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
2017-03-18 15:13:02 +02:00
alexey.lysiuk
0130fc27cc Fixed compilation with GCC/Clang
src/scripting/backend/codegen.cpp:317:35: error: cannot initialize return object of type 'FxExpression *' with an rvalue of type 'bool'
2017-03-18 14:31:15 +02:00
Christoph Oelckers
b416322032 - converted FInterBackground into a class so that the scripts can use it.
- fixed some issues with default value matching in savegames.
2017-03-18 13:25:22 +01:00
Christoph Oelckers
1e9ef2b1df - started scriptifying the level intermission screen. This compiles but is not active yet.
- allow treatment as one-character string constants as character constants. This became necessary because name constants already use single quotes and are much harder to repurpose due to a higher degree of ambiguity.
- fixed: protected methods in structs were not usable.
2017-03-18 12:18:15 +01:00
alexey.lysiuk
ce3c397ec7 Fixed builtin type names for -dumpast command line option 2017-03-18 13:11:13 +02:00
Christoph Oelckers
d506b2e6a1 - fixed code generation bug with bad class names in DECORATE.
- print attenuation info with 'listlights' CCMD.
2017-03-17 16:00:04 +01:00
Christoph Oelckers
64bdc8c495 - fixed some incomplete checks for static arrays.
- made AActor::OkaytoSwitchTarget scripted virtual.
2017-03-15 01:39:59 +01:00
Christoph Oelckers
d283beb063 - implemented static constant arrays in class scope. 2017-03-14 23:55:30 +01:00
Christoph Oelckers
6926875b21 - allow parsing of static constant arrays in class scope.
This is only the parsing part, the arrays are not yet getting evaluated.
This required quite a hacky workaround because the gramma couldn't be made to accept the rule. The scanner will check if a 'static' token is immediately followed by a 'const' token and will combine both to a new 'staticconst' token that does not create conflicts with other rules.
2017-03-14 20:22:37 +01:00
Christoph Oelckers
539af96b8e - fixed variable size mismatch and some warnings for 32 bit builds. 2017-03-14 18:48:51 +01:00
alexey.lysiuk
6b8ea7ead3 Fixed comparison of class names for functions and fields
https://mantis.zdoom.org/view.php?id=426
2017-03-14 15:50:05 +01:00
Christoph Oelckers
d1ce5e37fc - fixed another error in DispatchScriptProperty. That AST's data organization is really messed up... :( 2017-03-13 21:22:11 +01:00
alexey.lysiuk
3a039b1e44 Fixed compilation error reported by GCC 2017-03-13 22:05:55 +02:00
Christoph Oelckers
6037ecb6a1 - fixed: Getting the offset to the 'Size' field for static arrays should use a fixed offset, not the size of the defining variable, which, depending on where things are defined, can be different. 2017-03-13 20:27:46 +01:00
Christoph Oelckers
cc60b005a1 - fixed processing of parameter-less ZScript properties. 2017-03-13 19:57:20 +01:00
Christoph Oelckers
cd392e50e9 - added a dummy struct named '_' to define global variables. This can only be used internally.
This method was chosen because it avoids adding variable declarations to the global namespace which would have required a lot more work while polluting the grammar.
This way the global variables can be handled by a small bit of special coding in the struct generator.
2017-03-13 14:42:14 +01:00
Christoph Oelckers
5fd86cf98c - added some syntactic help to the ZScript parser to allow defining the arrays with native structs on the script side instead of having to define them internally. 2017-03-13 12:51:09 +01:00
Christoph Oelckers
61c91f05fc Merge branch '3.0_work'
# Conflicts:
#	src/gl/scene/gl_portal.cpp
#	src/r_plane.cpp
2017-03-12 20:31:34 +01:00
ZZYZX
0176c29ec2 Will not emit OP_SCOPE if self type can be checked at compile time. 2017-03-12 20:27:38 +01:00
ZZYZX
91e83bf3c6 Fixed DECORATE scope for duplicates 2017-03-12 20:27:38 +01:00
ZZYZX
bd889cc8f1 Fixed various virtualscope oddities; set scope for DECORATE classes to play. 2017-03-12 20:27:38 +01:00
Christoph Oelckers
bd7476fb8d - untangled r_defs.h from actor.h
Both files can now be included independently without causing problems.
This also required moving some inline functions into separate files and splitting off the GC definitions from dobject.h to ensure that r_defs does not need to pull in any part of the object hierarchy.
2017-03-10 02:22:42 +01:00
Christoph Oelckers
a4710bcdb0 - did a bit of header cleanup to reduce the dependency on dobject.h. 2017-03-09 23:30:42 +01:00
Christoph Oelckers
c008ddaf66 - replaced homegrown SWORD, SBYTE and uint32_t types. 2017-03-09 19:31:45 +01:00
Christoph Oelckers
878e6015df - made all iterator classes natively abstract so that they do not get a ConstructNative method so that OP_NEW can refuse creating them without the need to mark them as abstract.
- block creation of actors with the 'new' instruction. Unlike the above these cannot be made abstract because without ConstructNative they cannot be serialized.
2017-03-09 17:21:37 +01:00
Christoph Oelckers
77bac4f6fa - fixed code generation for min/max when the first operand was a local variable or constant.
The code for constants was not optimal because the first operand of the instructions cannot be constant. This was solved by swapping it with the second choice which will always be non-constant.
The code for local variables did not allocate a new destination register and would overwrite the first parameter's variable.
2017-03-09 09:36:12 +01:00
Christoph Oelckers
6dee9ff566 - replaced another large batch of homegrown type use. 2017-03-08 18:55:53 +01:00
Christoph Oelckers
1cb89c6b37 - fixed bad call to validate function. 2017-03-08 13:35:21 +01:00
Christoph Oelckers
d911cdcfe7 - missed a bit. 2017-03-07 22:18:50 +01:00
Christoph Oelckers
e2f3a09dd0 - refactored the scope check for VirtualScope calls.
It now uses a dedicated opcode instead of piggybacking on OP_CALL and it passes data that is closer to the VM. Symbols should be avoided at this level.
It also will skip the scope instruction if the code generator detects that both calling function and the self pointer type have the same scope, this assumes that subclasses cannot flip between UI and Play.
2017-03-07 22:17:48 +01:00