Commit graph

83 commits

Author SHA1 Message Date
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
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
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
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
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
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
ac95cba848 - fixed generic class type properties to handle "" and "none" as 'no class'. 2017-03-19 12:02:17 +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
6dee9ff566 - replaced another large batch of homegrown type use. 2017-03-08 18:55:53 +01:00
Christoph Oelckers
456ac64723 - implemented version checks for compile-time type determination and for class inheritance.
Note that in this system, DECORATE counts as version 2.0, so any data that should be available to DECORATE should not use version restriction.
2017-03-05 17:58:55 +01:00
Christoph Oelckers
c630b07011 - replaced SDWORD with int32_t globally.
This type wasn't used in the software rendering code so it could be removed already. The other homegrown types will have to be dealt with later.
2017-03-03 19:35:08 +01:00
Christoph Oelckers
168627f549 - native meta variables are not needed anymore. They were only a temporary aid to properly handle this, but now all have been redone. 2017-02-28 14:38:50 +01:00
Christoph Oelckers
851984efe0 - made GetDeathHeight a virtual scripted function.
- made GetGibHealth a virtual scripted function.
- removed a few more native meta properties.
2017-02-28 13:40:46 +01:00
Christoph Oelckers
b6a1fe7fc6 - scriptified the basic attack functions, its properties and the explosion properties to test the new metadata system. 2017-02-28 10:51:32 +01:00
Christoph Oelckers
78a66e001a - properly handle all meta properties for inventory items. 2017-02-28 00:45:16 +01:00
Christoph Oelckers
f343d36ea9 - implemented the basics of a working metadata system.
This will store class meta properties in a separate memory block so that it won't have to muck around with PClass - which made the implementation from the scripting branch relatively useless because extending the data wasn't particularly easy and also not well implemented. This can now be handled just like the defaults.
2017-02-27 23:28:19 +01:00
alexey.lysiuk
eb40e8bcf0 Removed DYNLIGHT preprocessor definition
https://mantis.zdoom.org/view.php?id=318
2017-02-22 23:02:58 +02:00
Christoph Oelckers
bb6e667f33 - removed some unneeded version.h #includes. 2017-02-20 01:42:53 +01:00
Christoph Oelckers
c01289e999 - added ZScript property handling for names, sounds and colors. 2017-02-14 23:28:49 +01:00
Christoph Oelckers
c77f6636f8 - moved the three remaining variables from PClassInventory to PClassActor so that PClassInventory can be removed. 2017-02-08 18:11:23 +01:00
Christoph Oelckers
5a81a4ca16 - moved a few things around to have them into better fitting places. 2017-02-08 12:24:08 +01:00
Christoph Oelckers
776509e68a - let skip_super use the AActor assignment operator. The blanket memcpy it used was clobbering some data.
- moved the Finalize method from PClassActor to AActor. Now that defaults get their vtbl pointer initialized this will actually work.
2017-02-07 18:12:59 +01:00
Christoph Oelckers
6d28aa3541 - do not use strtol for parsing critical values that can get large.
This function will truncate everything that is larger than LONG_MAX or smaller than LONG_MIN to fit into a long variable, but longs are 32 bit on Windows and 64 bit elsewhere, so to ensure consistency and the ability to parse larger values better use strtoll which does not truncate 32 bit values.
2017-02-01 11:19:55 +01:00
Christoph Oelckers
15b95cc023 - fixed: DECORATE was creating a new global constant namespace for each single included file, not just once per DECORATE lump. 2017-01-27 10:51:12 +01:00
Christoph Oelckers
c12dfd7e4d - fixed: only explicit class type casts must obey strict namespace rules, i.e. only '(class<type>)(variable_to_cast)'
The general rule is as follows: A class name as a string will always be looked up fully, even if the class name gets shadows by another variable because strings are not identifiers.
It is only class names as identifiers that must obey the rule that if it is not known yet or hidden by something else that it may not be found to ensure that the older variable does not take over the name if it gets reused.
2017-01-24 10:04:46 +01:00
Christoph Oelckers
b3aa7c61a9 - fixed: Class and struct name lookup was not context aware.
If a later module reused an existing name for a different class or struct type, this new name would completely shadow the old one, even in the base files.
Changed it so that each compilation unit (i.e. each ZScript and DECORATE lump) get their own symbol table and can only see the symbol tables that got defined in lower numbered resource files so that later definitions do not pollute the available list of symbols when running the compiler backend and code generator - which happens after everything has been parsed.

Another effect of this is that a mod that reuses the name of an internal global constant will only see its own constant, again reducing the risk of potential errors in case the internal definitions add some new values.

Global constants are still discouraged from being used because what this does not and can not handle is the case that a mod defines a global constant with the same name as a class variable. In such a case the class variable will always take precedence for code inside that class.

Note that the internal struct String had to be renamed for this because the stricter checks did not let the type String pass on the left side of a '.' anymore.

- made PEnum inherit from PInt and not from PNamedType.

The old inheritance broke nearly every check for integer compatibility in the compiler, so this hopefully leads to a working enum implementation.
2017-01-23 19:10:28 +01:00
Christoph Oelckers
3c30b59bab more inventory scriptification
* completely scriptified DehackedPickup and FakeInventory.
* scriptified all remaining virtual functions of Inventory, so that its inheritance is now 100% script-side.
* scriptified CallTryPickup and most of the code called by that.

- fixed: Passing local variables by reference did not work in the VM.
2017-01-19 23:42:12 +01:00
Christoph Oelckers
1750ded7c4 - more exporting of AInventory. 2017-01-19 20:56:31 +01:00
Christoph Oelckers
98f9219334 - scriptified the remaining functions in a_artifacts.cpp.
- added some helpers to set scripted member variables through the native property parser.

Unfortunately some classes, e.g. PowerMorph, MorphProjectile and the powerup contain some that cannot be handled through the 'property' definition on the script side so they need to be done from the native side.
2017-01-17 20:30:17 +01:00
Christoph Oelckers
c5f100a61d - fixed class name checks for custom properties. 2017-01-16 20:44:52 +01:00
Christoph Oelckers
65b7e344f7 - added custom property parsing to DECORATE as well. 2017-01-16 10:36:56 +01:00
Christoph Oelckers
71bda99c3b - fixed: DECORATE didn't pass all needed arguments to FunctionBuildList.AddFunction. Removed the default parameter values from this function's declaration to prevent it from happening again. 2016-12-03 18:14:07 +01:00
Christoph Oelckers
21e3aba1c7 - optionally allow passing a script position object to V_GetColor and subfunctions for better error output. Implemented this for all occurences where this info was available. 2016-12-03 16:27:53 +01:00
Christoph Oelckers
a13e23dbe6 - scriptified some trivial stuff from g_shared. 2016-11-29 19:50:34 +01:00
Christoph Oelckers
66d28a24b8 - disabled the scripted virtual function module after finding out that it only works if each single class that may serve as a parent for scripting is explicitly declared.
Needless to say, this is simply too volatile and would require constant active maintenance, not to mention a huge amount of work up front to get going.
It also hid a nasty problem with the Destroy method. Due to the way the garbage collector works, Destroy cannot be exposed to scripts as-is. It may be called from scripts but it may not be overridden from scripts because the garbage collector can call this function after all data needed for calling a scripted override has already been destroyed because if that data is also being collected there is no guarantee that proper order of destruction is observed. So for now Destroy is just a normal native method to scripted classes
2016-11-25 00:25:26 +01:00
Christoph Oelckers
0c95568d98 - exported native fields of several more classes. 2016-11-23 01:31:48 +01:00
Christoph Oelckers
03a02a2036 - updated copyrights in a few files. 2016-11-22 12:28:11 +01:00
Christoph Oelckers
135cfcf016 - implemented State as an actual native struct, so that its fields can be accessed from scripts.
- refactored state bitfield members into a flag word because the address of a bitfield cannot be taken, making such variables inaccessible to scripts.
- actually use PNativeStruct for representing native structs defined in a script.
2016-11-21 21:34:34 +01:00
Christoph Oelckers
f71aad4cdd - cleanup of the remaining FxBinary operators.
- changed FxCompareEq with strings and other types that can be cast to from a string always convert the string to the other type before comparing.
2016-11-18 14:19:55 +01:00
Christoph Oelckers
97e643c7e1 - fixed: DECORATE tried to resolved null states again, causing a type conflict. 2016-11-15 15:34:25 +01:00