Commit Graph

168 Commits

Author SHA1 Message Date
alexey.lysiuk 490fd8f3a0 Fixed applying of multiple damage factors
https://mantis.zdoom.org/view.php?id=586
2017-04-15 12:33:26 +03: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 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 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 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 63eb3e331e - un-const-ify some functions. 2017-04-12 14:40:29 +02:00
Christoph Oelckers 80801d11b1 - removed some redundant static_casts. 2017-04-12 10:29:04 +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 45691e91c9 - removed PClassActor::PointerSubstitution.
This is not needed anymore because classes do not need to be replaced. The only reason this was implemented was the original design with the class descriptors taking on all the metadata themselves.
2017-04-11 14:03:49 +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 00dc59ebdc - separated the blood translation index from the BloodColor variable to allow more than 255 blood translations and as a prerequisite for allowing to change the blood color. 2017-03-02 10:26:23 +01:00
Christoph Oelckers fc125f7eaf - reworked the obituary system to use scripted virtual overrides. Let's hope this solves the problems with the original code, now that any actor needing special treatment can override it. 2017-02-28 14:30:14 +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 d5250d6b9f - made WoundHealth modifiable to allow more control over the wound state. 2017-02-28 12:56:35 +01:00
Christoph Oelckers 2a4a5e7a70 - refactored a few more native meta properties. 2017-02-28 12:47:44 +01:00
Christoph Oelckers 1311f08f47 - scriptified Actor.GetBloodType as a virtual function to allow mods more flexibility here.
- made CameraHeight a modifiable actor property - it was readonly before.
- allow accessing the type constants from ZScript, this required quite a bit of explicit coding because the type system has no capabilities to search for basic types by name.
2017-02-28 12:11:25 +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 321c846d01 - added StealthAlpha actor property for defining a minimum visibility value of a stealth monster. 2017-02-27 19:46:27 +01:00
Christoph Oelckers 78538ed9ef - missed an else. 2017-02-27 14:53:39 +01:00
Christoph Oelckers f9f9f2d5fc - added selfdamagefactor actor property. 2017-02-27 11:22:51 +01:00
Christoph Oelckers 3d500f0495 - added default obituaries for damage types.
Note that this is only implemented for the new official way of doing this in MAPINFO, but not in DECORATE!
2017-02-26 21:36:06 +01:00
Christoph Oelckers 2234d36c7a Merge branch 'thereisnospoon' of https://github.com/jewalky/gzdoom
# Conflicts:
#	src/dobject.h
2017-02-14 19:10:02 +01:00
Christoph Oelckers 8277299135 - Turned DropItem into a plain struct again like it was before the scripting branch got merged.
Making this an object had little to no advantage, except being able to remove the deleter code. Now, with some of the class data already being allocated in a memory arena so that freeing it is easier, this can also be used for the drop item lists which makes it unnecessary to subject them to the GC. This also merges the memory arenas for VM functions and flat pointers because both get deleted at the same time so they can share the same one.
2017-02-08 20:37:22 +01:00
Christoph Oelckers 17a2666bd4 - moved DisplayName, the last remaining PlayerPawn meta property, to PClassActor so that PClassPlayerPawn could be removed.
Now all actors have the same metaclass and therefore it will always be the same size which will finally allow some needed changes to the type system which couldn't be done because it was occasionally necessary to replace tentatively created classes due to size mismatches.
2017-02-08 19:42:24 +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 a6785afddb - optimized the FName versions of IsDescendantOf and IsKindOf. These can be done without first looking up the class type itself. 2017-02-08 15:47:22 +01:00
Christoph Oelckers 3cbd62479b - took VMFunction out of the DObject hierarchy.
As it stood, just compiling the internal ZScript code created more than 9000 DObjects, none of which really need to be subjected to garbage collection, aside from allowing lazy deallocation.
This puts an incredible drag on the garbage collector which often needs several minutes to finish processing before actual deletion can start.

The VM functions with roughly 1800 of these objects were by far the easiest to refactor so they are now. They also use a memory arena now which significantly reduces their memory footprint.
2017-02-08 11:13:41 +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
ZZYZX efb1e5d33a Implemented global EventHandlers in MAPINFO 2017-01-23 20:48:57 +02:00
Christoph Oelckers 3148496f57 - scriptified BasicArmor and fixed a few errors in the conversion. 2017-01-18 22:15:48 +01:00
Christoph Oelckers 40e7fa5be2 - scriptified the RandomSpawner.
- fixed: String constants were not processed by the compiler backend.
- added an explicit name cast for class types.
2017-01-14 02:05:52 +01:00
Christoph Oelckers b3783a3850 redid the exception mechanism for script-side access violations to be of more use for diagnosing problems.
The original implementation just printed a mostly information-free message and then went on as if nothing has happened, making it ridiculously easy to write broken code and release it. Changed it to:

* Any VMAbortException will now terminate the game session and go back to the console.
* It will also print a VM stack trace with all open functions, including source file and line numbers pointing to the problem spots. For this the relevant information had to be added to the VMScriptFunction class.

An interesting effect here was that just throwing the exception object increased the VM's Exec function's stack size from 900 bytes to 70kb, because the compiler allocates a separate local buffer for every single instance of the exception object.
The obvious solution was to put this part into a subfunction so that it won't pollute the Exec function's own stack frame. Interesting side effect of this: Exec's stack requirement went down from 900 bytes to 600 bytes. This is still on the high side but already a lot better.
2016-12-03 12:23:13 +01:00
Christoph Oelckers 87484950cf - removed an assert from APowerMorph::EndEffect. With some recent changes to DestroyAllInventory it appears that the asserted condition no longer is true at this point when ending a game.
- fixed: When replacing a tentative class, the pointers in the morph objects were not replaced. Instead of adding more ReplaceClassRef methods I chose to integrate this part into the PointerSubstitution mechanism and delete ReplaceClassRef entirely. The code had some oversights anyway that would have caused problems, now that non-actors can be created.
2016-12-01 00:05:23 +01:00
Christoph Oelckers 86544086df - allow the VM to run on one global stack per thread.
It is utterly pointless to require every function that wants to make a VM call to allocate a new stack first. The allocation overhead doubles the time to set up the call.
With one stack, previously allocated memory can be reused. The only important thing is, if this ever gets used in a multithreaded environment to have the stack being declared as thread_local, although for ZDoom this is of no consequence.

- eliminated all cases where native code was calling other native code through the VM interface. After scriptifying the game code, only 5 places were left which were quickly eliminated. This was mostly to ensure that the native VM function parameters do not need to be propagated further than absolutely necessary.
2016-11-30 17:15:01 +01:00
Christoph Oelckers bbf62132d8 - added a larger batch of function exports.
- cleaned up the virtual function interface of APlayerPawn which still had many virtual declarations from old times when class properties were handled through virtual overrides. None of this makes sense these days anymore.
2016-11-30 01:25:51 +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 9ae272d753 - scriptified Heretic's blaster.
- scriptified all Effect functions of Fastprojectile's children
- implemented access to class meta data.
- added a VM instruction to retrieve the class metadata, to eliminate the overhead of the function call that would otherwise be needed.
- made GetClass() a builtin so that it can use the new instruction

Important note about this commit: Scriptifying CFlameMissile::Effect revealed a problem with the virtual function interface: In order to work, this needs to be explicitly enabled for each single native class that may be used as a base for a scripted class. Needless to say, this will end up way too much work, as there are over 100 native classes, excluding those which will be scriptified. But in order to fix the problem this partially broken state needs to be committed first.
2016-11-24 20:02:44 +01:00
Christoph Oelckers d86f03e2e0 - reverted most of the last commit after realizing that trying to manage constructing/destructing per variable is not going to work because it'd require some extensive exception management in the compiled VM code.
- instead add a list of SpecialInits to VMScriptFunction so this can be done transparently when setting up and popping the stack frame. The only drawback is that this requires permanent allocation of stack objects for the entire lifetime of a function but this is a relatively small tradeoff for significantly reduced maintenance work throughout.
- removed most #include "vm.h", because nearly all files already pull this in through dobject.h.
2016-11-17 13:10:19 +01:00
Christoph Oelckers 384f4fe7ce - added a 'DefaultStateUsage' property so that this setting can be properly set up for the classes that can inject states into other actors. 2016-11-14 18:31:12 +01:00
Christoph Oelckers 6529931281 fixed and completed the special field init code. Strings can now be used as class members, and so can structs which contain strings.
- made 'DamageMultiply' an actor property and moved the initialization of ConversationRoot to the property handler for the compiler to get this stuff out of the type classes.
- consolidate default initialization into one function which performs all the required setup. The original implementation did this when adding the fields but that cannot work because at that time no defaults have been created yet.
- fixed: When deriving a class the child class's defaults also must initialize the copied parent fields with special initialization. This part was completely missing.
- removed DECORATE code for parsing native classes because it's no longer needed.
2016-11-11 14:40:32 +01:00
Leonard2 7dbc4710f1 Add the new argument to all uses of the implement macro 2016-11-09 17:45:55 +01:00